:root {
  --bg: #f4f2eb;
  --paper: #fffefa;
  --soft: #eeece5;
  --panel: #ffffff;
  --panel-2: #e9e7df;
  --line: #cbc9c0;
  --line-strong: #8e8c84;
  --muted: #68675f;
  --text: #171714;
  --accent: #c6ff4a;
  --danger: #a5271b;
  --max-width: 1180px;
  --z-base: 0;
  --z-sticky: 10;
  --z-popover: 30;
  --z-modal: 90;
  --z-toast: 100;
}

html {
  scroll-behavior: smooth;
  /* Reserve the scrollbar track so a growing page (e.g. a rendered result)
     cannot shift the whole layout sideways on desktop. */
  scrollbar-gutter: stable;
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: var(--ui-font-sans);
}

button,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

h1,
h2,
h3 {
  text-wrap: balance;
  /* Long single words ("handwriting", "mathematical") are wider than a narrow
     phone's column at display sizes. Only breaks when the word cannot fit. */
  overflow-wrap: break-word;
}

p,
li {
  text-wrap: pretty;
}

.site-header,
main,
.global-footer {
  width: min(var(--max-width), calc(100% - 40px));
  margin-inline: auto;
}

/* Header and navigation */
.site-header {
  display: grid;
  min-height: 82px;
  /* Brand, navigation, menu toggle. The retired social icon used to hold a fourth
     column here; keeping a track for it would leave an empty gap. */
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  color: var(--text);
  background: var(--accent);
  border: 1px solid var(--text);
  border-radius: 2px;
  font: 700 16px/1 var(--ui-font-sans);
}

.brand-name {
  font: 700 20px/1 var(--ui-font-sans);
}

.brand-discipline {
  margin-left: 5px;
  padding-left: 14px;
  color: var(--muted);
  border-left: 1px solid var(--line);
  font-size: 10px;
  text-transform: uppercase;
}

.main-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 22px;
  margin-left: auto;
}

.main-nav a {
  position: relative;
  padding: 31px 0 29px;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}

.main-nav a:hover,
.main-nav a[aria-current="page"] {
  color: var(--text);
}

.primary-link,
.extension-jump {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 42px;
  padding: 0 15px;
  color: #fff;
  background: var(--text);
  border: 1px solid var(--text);
  border-radius: 2px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  transition: transform 140ms ease-out;
}

.primary-link:hover,
.extension-jump:hover {
  transform: translateY(-2px);
}

.nav-toggle {
  display: none;
  width: 42px;
  height: 40px;
  padding: 10px;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--text);
  border-radius: 2px;
}

.nav-toggle span {
  display: block;
  width: 100%;
  height: 1px;
  margin: 4px 0;
  background: var(--text);
  transition: transform 140ms ease-out, opacity 140ms ease-out;
}

.nav-toggle.open span:nth-child(1) {
  transform: translateY(5px) rotate(45deg);
}

.nav-toggle.open span:nth-child(2) {
  opacity: 0;
}

.nav-toggle.open span:nth-child(3) {
  transform: translateY(-5px) rotate(-45deg);
}

/* Shared type and links */
.eyebrow,
.section-number,
.product-type,
.field-label,
.preview-heading,
.file-types,
.output-status {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font: 600 clamp(52px, 7.4vw, 104px)/0.94 var(--ui-font-sans);
}

h2 {
  margin: 0;
  font: 600 clamp(32px, 4.4vw, 58px)/1.02 var(--ui-font-sans);
}

h3 {
  margin: 0;
  font: 600 22px/1.15 var(--ui-font-sans);
}

.secondary-link {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  padding: 0 15px;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--text);
  border-radius: 2px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  transition: transform 140ms ease-out;
}

.secondary-link:hover {
  transform: translateY(-2px);
}

.tool-switch-link,
.external-link,
.card-link {
  color: var(--muted);
  font-size: 12px;
  text-underline-offset: 4px;
}

.tool-switch-link {
  text-decoration: none;
}

.tool-switch-link strong,
.external-link,
.card-link,
.brand-highlight {
  color: var(--text);
}

/* Homepage */
.home-hero {
  display: grid;
  min-height: 690px;
  grid-template-columns: 1.08fr 0.92fr;
  align-items: center;
  gap: clamp(45px, 7vw, 90px);
  padding: 86px 0 92px;
}

.home-copy h1 {
  margin: 18px 0 24px;
}

/*
 * One typeface per heading. The accent line is set apart by weight and size,
 * never by swapping families: a serif second line inside a sans heading reads
 * as a broken font load, not as a deliberate accent.
 */
.home-copy h1 span {
  display: inline-block;
  font-family: var(--ui-font-sans);
  font-size: 0.78em;
  font-weight: 500;
  line-height: 1.05;
  white-space: nowrap;
}

.home-copy > p:not(.eyebrow) {
  max-width: 590px;
  margin: 0;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.65;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 34px;
}

.hero-proof {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-top: 54px;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.hero-proof span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hero-proof b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.hero-proof i {
  width: 30px;
  height: 1px;
  background: var(--line-strong);
}

.equation-art {
  position: relative;
  display: flex;
  min-height: 450px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.art-label {
  align-self: flex-start;
  margin: 0 0 8px 11%;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

.paper-card {
  position: relative;
  display: grid;
  width: 78%;
  min-height: 150px;
  padding: 28px 34px;
  place-items: center;
  overflow: hidden;
  color: var(--text);
  background: #e8e8df;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  box-shadow: 20px 25px 60px rgb(27 34 20 / 16%);
  transform: rotate(-2.5deg);
}

.paper-card::before {
  position: absolute;
  inset: 0;
  content: "";
  border-block: 1px solid rgb(142 167 191 / 28%);
  opacity: 0.55;
}

.scribble {
  position: relative;
  z-index: var(--z-sticky);
  width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: center;
  font: italic 25px/1.2 Georgia, serif;
}

.scan-line {
  position: absolute;
  z-index: var(--z-popover);
  top: 18%;
  right: 0;
  left: 0;
  height: 2px;
  opacity: 0.25;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: scan 3.2s ease-out infinite;
  animation-play-state: paused;
}

.equation-art.is-scanning .scan-line {
  animation-play-state: running;
}

@keyframes scan {
  0%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }

  50% {
    opacity: 1;
    transform: translateY(96px);
  }
}

.transform-arrow {
  z-index: var(--z-sticky);
  margin: 13px 0;
  color: var(--text);
  font-size: 18px;
}

.code-card {
  position: relative;
  z-index: var(--z-sticky);
  width: 86%;
  padding: 18px;
  color: #d7dccd;
  background: var(--text);
  border: 1px solid #3e4039;
  border-radius: 5px;
  box-shadow: 0 20px 45px rgb(27 34 20 / 12%);
  transform: rotate(1.5deg);
}

.code-card span {
  display: block;
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
}

.code-card code {
  display: block;
  overflow-wrap: anywhere;
  font: 12px/1.7 var(--ui-font-mono);
}

.art-orbit {
  position: absolute;
  z-index: -1;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.orbit-one {
  width: 430px;
  height: 430px;
}

.orbit-two {
  width: 330px;
  height: 330px;
}

.workflow-section {
  padding: 18px 0 100px;
}

.student-guide-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  margin-top: 16px;
  padding: 28px;
  background: var(--accent);
  border: 1px solid var(--text);
}

.student-guide-callout span {
  font-size: 9px;
  font-weight: 700;
}

.student-guide-callout h2 {
  margin: 6px 0 5px;
  font-size: 26px;
}

.student-guide-callout p {
  max-width: 700px;
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
}

.product-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.product-card {
  position: relative;
  min-height: 390px;
  padding: 34px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--ui-shadow-sm);
}

.product-number {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

.product-card h3 {
  margin: 32px 0 15px;
  font: 600 36px/1.1 var(--ui-font-sans);
}

.product-card > p {
  max-width: 480px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
}

.product-card ul {
  display: grid;
  gap: 9px;
  margin: 25px 0 34px;
  padding: 0;
  color: var(--muted);
  font-size: 12px;
  list-style: none;
}

.product-card li::before {
  margin-right: 10px;
  content: "\00b7";
  color: var(--text);
}

.product-card > a {
  display: inline-flex;
}

/* Converter */
.page-intro {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 35px;
  row-gap: 0;
  align-items: end;
  padding: 65px 0 34px;
}

.page-intro .eyebrow {
  grid-column: 1;
  grid-row: 1;
}

.page-intro h1 {
  grid-column: 1;
  grid-row: 2;
  margin: 12px 0 11px;
  font-size: clamp(48px, 6.4vw, 82px);
}

.page-intro > p:last-of-type {
  grid-column: 1;
  grid-row: 3;
  max-width: 650px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.page-intro .tool-switch-link {
  grid-column: 2;
  grid-row: 3;
  margin: 0;
  white-space: nowrap;
}

.workspace {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  gap: 32px;
  margin-bottom: 62px;
  padding: 28px 28px 64px;
  background: var(--panel);
  border: 1px solid var(--text);
  box-shadow: 10px 10px 0 var(--panel-2);
}

.panel {
  min-width: 0;
  padding: 0;
}

.input-panel {
  border-right: 0;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.panel-heading h2 {
  font-size: 19px;
}

.drop-zone {
  width: 100%;
  height: 282px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  background: #f7f6f1;
  border: 1px dashed var(--line-strong);
  border-radius: 2px;
  transition: transform 140ms ease-out;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.dragover {
  border-color: var(--text);
}

.drop-zone.dragover {
  transform: scale(0.99);
}

.upload-prompt {
  display: flex;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
}

.upload-prompt strong {
  color: var(--text);
  font-size: 15px;
}

.upload-prompt span {
  font-size: 13px;
}

.upload-prompt u {
  color: var(--text);
  text-underline-offset: 3px;
}

.upload-prompt small {
  margin-top: 5px;
  font-size: 10px;
}

.ai-data-notice {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
  text-wrap: pretty;
}

.ai-data-notice a {
  color: var(--text);
  font-weight: 700;
  text-underline-offset: 3px;
}

.upload-icon {
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 10px;
  place-items: center;
  color: var(--text);
  background: var(--accent);
  border: 1px solid var(--text);
  border-radius: 50%;
  font-size: 20px !important;
}

.preview-wrap {
  position: relative;
  height: 100%;
  padding: 12px;
}

.preview-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.change-badge {
  position: absolute;
  right: 18px;
  bottom: 18px;
  padding: 7px 10px;
  color: #fff;
  background: var(--text);
  border-radius: 2px;
  font-size: 10px;
}

.crop-toolbar {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 9px;
  margin: 12px 0 0;
}

.crop-tool-button,
.crop-presets button {
  padding: 8px 11px;
  cursor: pointer;
  color: var(--text);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  font: 700 10px/1 var(--ui-font-sans);
}

.crop-tool-button:hover,
.crop-tool-button:focus-visible,
.crop-presets button:hover,
.crop-presets button:focus-visible {
  background: var(--accent);
  border-color: var(--text);
}

.crop-status {
  margin-right: auto;
  color: var(--muted);
  font-size: 10px;
}

.crop-restore-button {
  color: var(--muted);
  background: transparent;
}

.crop-modal-backdrop {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  padding: 24px;
  place-items: center;
  overflow: auto;
  background: rgba(17, 17, 16, 0.72);
}

.crop-modal {
  width: min(860px, 100%);
  padding: 24px;
  background: var(--paper);
  border: 1px solid var(--text);
  box-shadow: 12px 12px 0 rgba(17, 17, 16, 0.24);
}

.crop-modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.crop-modal-heading span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.13em;
}

.crop-modal-heading h2 {
  margin-top: 3px;
  font-size: 25px;
}

.crop-close {
  width: 38px;
  height: 38px;
  padding: 0;
  cursor: pointer;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 2px;
  font-size: 23px;
}

.crop-modal > p {
  max-width: 660px;
  margin: 10px 0 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.crop-stage {
  display: grid;
  min-height: 260px;
  padding: 14px;
  place-items: center;
  overflow: auto;
  background: #1b1b19;
  border: 1px solid var(--text);
}

#crop-canvas {
  display: block;
  max-width: 100%;
  cursor: crosshair;
  background: #fff;
  outline: 0;
  touch-action: none;
}

#crop-canvas:focus-visible {
  box-shadow: 0 0 0 3px var(--accent);
}

.crop-selection-row {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 11px;
}

.crop-presets {
  display: flex;
  gap: 7px;
}

.crop-modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.crop-modal-actions .primary-button {
  margin-top: 0;
}

body.crop-modal-open {
  overflow: hidden;
}

.file-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 0;
  padding: 10px 12px;
  background: #f7f6f1;
  border: 1px solid var(--line);
}

.file-info {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.file-info div {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.file-info strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-info small {
  color: var(--muted);
  font-size: 10px;
}

.file-icon {
  font-size: 9px;
  font-weight: 700;
}

.icon-button {
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  border: 0;
  font-size: 21px;
}

.primary-button,
.secondary-button {
  display: flex;
  width: 100%;
  height: 47px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  border-radius: 2px;
  font-weight: 700;
  transition: transform 140ms ease-out, opacity 140ms ease-out;
}

.primary-button {
  margin-top: 14px;
  color: #fff;
  background: var(--text);
  border: 1px solid var(--text);
}

.primary-button:not(:disabled):hover,
.secondary-button:not(:disabled):hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.button-arrow {
  font-size: 18px;
}

.secondary-button {
  color: var(--text);
  background: #f7f6f1;
  border: 1px solid var(--line);
}

.accent-button {
  background: var(--accent);
  border-color: var(--text);
}

.message {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 2px;
  font-size: 12px;
  line-height: 1.45;
}

.error-message {
  color: var(--danger);
  background: #fff4f2;
  border: 1px solid #e4aaa4;
}

.field-label,
.preview-heading {
  display: flex;
  justify-content: space-between;
}

textarea {
  width: 100%;
  height: 148px;
  margin: 9px 0 20px;
  padding: 15px;
  resize: vertical;
  color: var(--text);
  background: #f7f6f1;
  border: 1px solid var(--line);
  border-radius: 2px;
  font: 14px/1.55 var(--ui-font-mono);
}

textarea:focus-visible {
  border-color: var(--text);
}

textarea:disabled {
  opacity: 0.58;
}

.mathjax-label {
  color: var(--muted);
  font-weight: 400;
  text-transform: none;
}

.equation-preview {
  display: grid;
  min-height: 122px;
  margin: 9px 0 14px;
  padding: 17px;
  place-items: center;
  overflow: auto;
  color: var(--text);
  background: var(--paper);
  border: 1px solid var(--line);
}

.preview-placeholder {
  color: var(--muted);
  text-align: center;
}

.preview-placeholder span {
  font: 28px Georgia, serif;
}

.preview-placeholder p {
  margin: 6px 0 0;
  font-size: 10px;
}

.equation-preview mjx-container {
  width: 100%;
  max-width: 100%;
  margin: 0 !important;
  text-align: center;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.quiet-reset {
  width: 100%;
  margin-top: 10px;
  padding: 9px;
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  border: 0;
  font-size: 11px;
}

.quiet-reset:not(:disabled):hover {
  color: var(--text);
}

.quiet-reset:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.converter-help-button {
  position: absolute;
  z-index: var(--z-sticky);
  bottom: 16px;
  left: 28px;
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  cursor: pointer;
  background: var(--paper);
  border: 1px solid var(--text);
  border-radius: 50%;
  font: 700 14px/1 var(--ui-font-sans);
}

.converter-help-button:hover,
.converter-help-button[aria-expanded="true"] {
  color: #fff;
  background: var(--text);
}

.converter-help-panel {
  position: absolute;
  z-index: var(--z-popover);
  bottom: 60px;
  left: 20px;
  width: min(400px, calc(100% - 40px));
  max-height: calc(100% - 80px);
  padding: 20px;
  overflow: auto;
  background: var(--paper);
  border: 1px solid var(--text);
  box-shadow: 8px 8px 0 var(--panel-2);
}

.converter-help-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.converter-help-heading span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

.converter-help-heading h2 {
  margin-top: 5px;
  font-size: 22px;
}

.converter-help-heading button {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  padding: 0;
  place-items: center;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 19px;
}

.converter-help-panel > p {
  margin: 14px 0 16px;
  color: var(--muted);
  font-size: 12px;
}

.converter-help-panel ul {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.converter-help-panel li {
  display: grid;
  gap: 4px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}

.converter-help-panel li strong {
  font-size: 12px;
}

.converter-help-panel li span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.trust-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 62px 0 90px;
  border-top: 1px solid var(--text);
  border-bottom: 1px solid var(--text);
}

.trust-row > div {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 23px 16px;
}

.trust-row > div + div {
  border-left: 1px solid var(--line);
}

.trust-row > div > span {
  font-size: 20px;
}

.trust-row p {
  display: flex;
  margin: 0;
  flex-direction: column;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

.trust-row strong {
  color: var(--text);
  font-size: 12px;
}

/* Google add-on */
.extension-hero {
  display: grid;
  min-height: 620px;
  grid-template-columns: 1.05fr 0.95fr;
  align-items: center;
  gap: 80px;
  padding: 82px 0 76px;
}

.extension-copy h1 {
  margin: 18px 0 25px;
  font-size: clamp(48px, 6.3vw, 84px);
}

.extension-copy h1 span {
  font-family: var(--ui-font-sans);
  font-weight: 500;
}

.extension-copy > p:not(.eyebrow) {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}

.extension-actions {
  margin-top: 28px;
}

.extension-availability {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 11px;
}

.addon-preview {
  overflow: hidden;
  color: #20201d;
  background: #fffefa;
  border: 1px solid var(--text);
  box-shadow: 10px 10px 0 var(--panel-2);
}

.addon-preview-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.addon-preview-header > div:nth-child(2) {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.addon-preview-header strong {
  font-size: 13px;
}

.addon-preview-header > div:nth-child(2) span {
  color: var(--muted);
  font-size: 8px;
}

.addon-preview-icons {
  display: flex;
  gap: 5px;
}

.addon-preview-icons span {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 1px solid var(--line);
  font-size: 10px;
}

.addon-preview-status,
.addon-preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  color: var(--muted);
  background: #f5f4ee;
  font-size: 8px;
}

.addon-preview-status span:last-child,
.addon-preview-footer {
  display: flex;
  align-items: center;
  gap: 5px;
}

.addon-preview-status i,
.addon-preview-footer i {
  display: block;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border: 1px solid var(--text);
  border-radius: 50%;
}

.addon-preview-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.addon-preview-tabs span,
.addon-preview-tabs b {
  padding: 10px 3px;
  color: var(--muted);
  border-right: 1px solid var(--line);
  font-size: 8px;
  text-align: center;
}

.addon-preview-tabs b {
  color: var(--text);
  background: var(--accent);
}

.addon-preview-appearance {
  display: flex;
  justify-content: space-between;
  padding: 9px 14px;
  background: #f5f4ee;
  border-bottom: 1px solid var(--line);
  font-size: 8px;
}

.addon-preview-body {
  padding: 22px 18px 25px;
}

.addon-preview-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.addon-preview-title h2 {
  margin: 0 0 3px;
  font-size: 20px;
}

.addon-preview-title p,
.addon-preview-title > span {
  margin: 0;
  color: var(--muted);
  font-size: 8px;
}

.addon-preview-body > label {
  display: block;
  margin: 18px 0 6px;
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
}

.addon-preview-input {
  min-height: 74px;
  padding: 11px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  font-size: 10px;
  line-height: 1.5;
}

.addon-preview-chips {
  display: flex;
  gap: 5px;
  margin: 8px 0 13px;
}

.addon-preview-chips span {
  padding: 5px 7px;
  background: #f5f4ee;
  border: 1px solid var(--line);
  font-size: 7px;
}

.addon-preview-button {
  padding: 11px;
  color: #fff;
  background: var(--text);
  font-size: 9px;
  font-weight: 700;
  text-align: center;
}

.addon-preview-footer {
  justify-content: flex-start;
  border-top: 1px solid var(--line);
}

.extension-mock {
  padding: 16px;
  background: var(--text);
  border: 1px solid var(--text);
  box-shadow: 10px 10px 0 var(--panel-2);
}

.extension-mock-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 1px 14px;
  color: #aaa99f;
  font-size: 9px;
  text-transform: uppercase;
}

.extension-mock-bar strong {
  color: var(--accent);
}

.extension-doc {
  min-height: 320px;
  padding: 34px;
  color: var(--text);
  background: var(--paper);
}

.extension-doc > span {
  color: var(--muted);
  font: 12px Georgia, serif;
}

.extension-doc h3 {
  margin: 50px 0 18px;
  font-size: 21px;
}

.extension-equation {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 26px;
  padding: 21px;
  background: #f0fbd5;
  border: 1px solid var(--text);
  font-size: 19px;
}

.extension-equation mjx-container {
  margin: 0 !important;
}

.extension-features {
  scroll-margin-top: 20px;
  padding: 30px 0 100px;
}

.extension-heading {
  margin-bottom: 22px;
}

.extension-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--text);
  border-bottom: 1px solid var(--text);
}

.extension-grid article {
  min-width: 0;
  min-height: 300px;
  padding: 25px;
}

.extension-grid article + article {
  border-left: 1px solid var(--line);
}

.extension-grid article > span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

.extension-grid h3 {
  margin: 65px 0 14px;
  font-size: 20px;
}

.extension-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.extension-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 95px;
  padding: 32px;
  background: var(--paper);
  border: 1px solid var(--text);
}

.extension-note h2 {
  margin: 0 0 8px;
  font-size: 27px;
}

.extension-note > div > span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

.extension-note p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

/* Shared editorial pages */
.content-page {
  padding-bottom: 100px;
}

.content-hero {
  max-width: 900px;
  padding: 92px 0 55px;
}

.content-hero h1 {
  margin: 17px 0 22px;
  font-size: clamp(52px, 8vw, 92px);
}

.content-hero h1 span {
  font-family: var(--ui-font-sans);
  font-weight: 500;
}

.content-hero-lead {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}

.content-shortcuts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 80px;
  border: 1px solid var(--text);
}

.content-shortcuts a {
  padding: 15px;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.content-shortcuts a + a {
  border-left: 1px solid var(--line);
}

.content-shortcuts a:hover,
.content-shortcuts a:focus-visible {
  background: var(--accent);
}

.content-section-heading {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 25px;
  margin-bottom: 28px;
  padding-top: 28px;
  border-top: 1px solid var(--text);
}

.content-section-heading > span {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.content-section-heading h2 {
  margin: 7px 0 0;
  font-size: clamp(30px, 4vw, 48px);
}

.content-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.42fr) minmax(0, 1.58fr);
  gap: 50px;
  scroll-margin-top: 20px;
  padding: 34px 0 44px;
  border-top: 1px solid var(--line);
}

.content-shortcuts + .content-row,
.content-shortcuts + .story-chapter .content-section-heading {
  border-top-color: var(--text);
}

.content-row-label {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 12px;
  align-items: start;
}

.content-row-label > span {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.content-row-body h2 {
  max-width: 780px;
  margin: 0 0 16px;
  font-size: clamp(28px, 3.6vw, 42px);
}

.content-row-body p,
.content-row-body li {
  max-width: 800px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.content-row-body p {
  margin: 0;
}

.content-row-body p + p {
  margin-top: 14px;
}

.content-row-body ul {
  display: grid;
  gap: 9px;
  margin: 0;
  padding-left: 19px;
}

.content-row-body a {
  color: var(--text);
  text-underline-offset: 4px;
}

.policy-effective {
  width: fit-content;
  margin: 24px 0 0;
  padding: 7px 9px;
  color: var(--text);
  background: var(--soft);
  border: 1px solid var(--line);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.content-cta {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 60px;
  align-items: center;
  margin-top: 45px;
  padding: 38px;
  color: #fff;
  background: var(--text);
}

.content-cta h2 {
  margin: 8px 0 0;
  font-size: 32px;
}

.content-cta > div:last-child {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 12px;
}

.content-cta p {
  margin: 0;
  color: #deded7;
  font-size: 13px;
  line-height: 1.7;
}

.content-cta a {
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-underline-offset: 5px;
}

/* Story */
.story-chapter {
  scroll-margin-top: 20px;
  padding-bottom: 95px;
}

.story-chapter .timeline {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--text);
}

.timeline article {
  position: relative;
  min-height: 275px;
  padding: 28px;
}

.timeline article + article {
  border-left: 1px solid var(--line);
}

.timeline-dot {
  position: absolute;
  top: 28px;
  right: 28px;
  width: 10px;
  height: 10px;
  background: var(--accent);
  border: 1px solid var(--text);
}

.timeline-year {
  margin: 0 0 52px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

.timeline h3 {
  margin: 0 0 12px;
  font-size: 22px;
}

.timeline article > p:not(.timeline-year) {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.timeline-link {
  display: inline-flex;
  margin-top: 18px;
}

.story-current {
  display: grid;
  grid-template-columns: minmax(120px, 0.45fr) minmax(220px, 0.7fr) minmax(0, 1.25fr);
  gap: 32px;
  align-items: start;
  padding: 28px;
  background: var(--accent);
  border: 1px solid var(--text);
}

.story-current > span {
  font-size: 9px;
  font-weight: 700;
}

.story-current h3 {
  font-size: 24px;
}

.story-current p {
  margin: 0;
  color: #36362f;
  font-size: 13px;
  line-height: 1.7;
}

.story-current .secondary-link {
  grid-column: 3;
  width: fit-content;
  background: var(--paper);
}

/* Student guide */
.guide-section {
  scroll-margin-top: 20px;
  padding: 0 0 95px;
}

.guide-choice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--text);
}

.guide-choice-grid article {
  display: flex;
  min-height: 260px;
  padding: 25px;
  flex-direction: column;
}

.guide-choice-grid article + article {
  border-left: 1px solid var(--line);
}

.guide-choice-grid strong {
  font-size: 18px;
}

.guide-choice-grid p {
  margin: 45px 0 24px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.guide-choice-grid a {
  margin-top: auto;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
}

.latex-foundations article {
  min-height: 330px;
}

.latex-foundations code,
.latex-reference-grid code,
.latex-build code,
.latex-mistakes code,
.guide-practice code {
  font-family: var(--ui-font-mono);
}

.latex-foundations p code,
.latex-mistakes h3 code {
  padding: 2px 4px;
  background: var(--soft);
  border: 1px solid var(--line);
}

.latex-foundation-example {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding: 13px;
  background: var(--soft);
  border: 1px solid var(--line);
  font-size: 14px;
}

.latex-foundation-example > span:last-child {
  min-width: 70px;
  text-align: center;
}

.latex-reference-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--text);
}

.latex-reference-grid article {
  display: grid;
  min-height: 270px;
  grid-template-rows: auto auto auto 1fr;
  padding: 24px;
}

.latex-reference-grid article:nth-child(even) {
  border-left: 1px solid var(--line);
}

.latex-reference-grid article:nth-child(n + 3) {
  border-top: 1px solid var(--line);
}

.latex-reference-grid article > span,
.latex-build-heading span,
.latex-mistakes article > span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

.latex-reference-grid h3 {
  margin: 9px 0 18px;
  font-size: 17px;
}

.latex-source {
  display: block;
  width: 100%;
  overflow-x: auto;
  padding: 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
}

.latex-render {
  display: grid;
  min-height: 82px;
  place-items: center;
  overflow-x: auto;
  padding: 12px;
}

.guide-steps {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--text);
}

.guide-steps li {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 25px;
  padding: 23px;
}

.guide-steps li + li {
  border-top: 1px solid var(--line);
}

.guide-steps li > span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  background: var(--accent);
  border: 1px solid var(--text);
  font-size: 11px;
  font-weight: 700;
}

.guide-steps strong {
  font-size: 15px;
}

.guide-steps p {
  max-width: 790px;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.guide-steps div > code {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin-top: 8px;
  overflow-x: auto;
  padding: 7px 9px;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
}

.guide-build-section {
  display: grid;
  gap: 35px;
}

.guide-build-section > .guide-section-heading {
  margin-bottom: 0;
}

.latex-build {
  border: 1px solid var(--text);
}

.latex-build + .latex-build {
  margin-top: 20px;
}

.latex-build-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 0.7fr);
  gap: 35px;
  align-items: center;
  padding: 25px;
  background: var(--accent);
  border-bottom: 1px solid var(--text);
}

.latex-build-heading h3 {
  margin: 8px 0 0;
  font-size: 24px;
}

.latex-build-result {
  min-width: 0;
  overflow-x: auto;
  text-align: center;
}

.latex-build .guide-steps {
  border: 0;
}

.latex-mistakes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--text);
}

.latex-mistakes article {
  min-height: 220px;
  padding: 24px;
}

.latex-mistakes article:nth-child(even) {
  border-left: 1px solid var(--line);
}

.latex-mistakes article:nth-child(n + 3) {
  border-top: 1px solid var(--line);
}

.latex-mistakes h3 {
  margin: 40px 0 10px;
  font-size: 18px;
  text-wrap: balance;
}

.latex-mistakes p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  text-wrap: pretty;
}

.guide-practice-list {
  border: 1px solid var(--text);
}

.guide-practice details + details {
  border-top: 1px solid var(--line);
}

.guide-practice summary {
  display: grid;
  grid-template-columns: 55px 1fr;
  gap: 15px;
  padding: 20px 22px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.guide-practice summary:hover,
.guide-practice summary:focus-visible {
  background: var(--accent);
}

.guide-practice summary span {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 10px;
}

.guide-practice details > div {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 25px;
  align-items: center;
  padding: 18px 22px 24px 92px;
  background: var(--soft);
  border-top: 1px solid var(--line);
}

.guide-practice details > div > code {
  overflow-x: auto;
  padding: 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  font-size: 13px;
}

.guide-practice details > div > span {
  min-width: 0;
  overflow-x: auto;
  text-align: center;
}

.guide-checklist {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 60px;
  margin-bottom: 100px;
  padding: 38px;
  color: #fff;
  background: var(--text);
}

.guide-checklist h2 {
  margin: 8px 0 0;
  font-size: 32px;
}

.guide-checklist ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
}

.guide-checklist li {
  color: #deded7;
  font-size: 13px;
  line-height: 1.6;
}

.guide-next-step {
  align-items: center;
}

.guide-next-step > div:last-child > p {
  margin: 0;
  color: #deded7;
  font-size: 13px;
  line-height: 1.7;
  text-wrap: pretty;
}

.guide-next-actions {
  display: flex;
  gap: 20px;
  margin-top: 22px;
}

.guide-next-actions a {
  padding-bottom: 4px;
  color: #fff;
  border-bottom: 1px solid #fff;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
}

/* Focused search pages */
.search-page {
  padding-bottom: 100px;
}

.search-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.45fr);
  gap: 70px;
  align-items: end;
  padding: 92px 0 82px;
}

.search-hero h1,
.search-section h2,
.search-cta h2,
.search-related h2 {
  text-wrap: balance;
}

.search-hero h1 {
  max-width: 980px;
  margin: 17px 0 24px;
  font-size: clamp(48px, 7.3vw, 88px);
}

.search-hero h1 span {
  font-family: var(--ui-font-sans);
  font-weight: 500;
}

.search-lead,
.search-section-heading > div > p,
.search-tips > div > p,
.search-cta p,
.search-status p {
  text-wrap: pretty;
}

.search-lead {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.72;
}

.search-actions {
  display: flex;
  gap: 22px;
  align-items: center;
  margin-top: 30px;
}

.search-text-link {
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
}

.search-status {
  padding: 25px;
  background: var(--accent);
  border: 1px solid var(--text);
}

.search-status > span {
  display: block;
  margin-bottom: 34px;
  font-size: 9px;
  font-weight: 700;
}

.search-status strong {
  display: block;
  font-size: 20px;
  line-height: 1.25;
}

.search-status p {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.65;
}

.search-section {
  padding: 80px 0;
  border-top: 1px solid var(--text);
}

.search-section-heading {
  display: grid;
  grid-template-columns: minmax(160px, 0.42fr) minmax(0, 1.58fr);
  gap: 50px;
  margin-bottom: 35px;
}

.search-section-heading h2 {
  max-width: 820px;
  margin: 0;
  font-size: clamp(32px, 4.5vw, 54px);
}

.search-section-heading > div > p {
  max-width: 760px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.search-use-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--text);
}

.search-use-grid article {
  min-height: 260px;
  padding: 25px;
}

.search-use-grid article + article {
  border-left: 1px solid var(--line);
}

.search-use-grid article > span {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 10px;
  font-weight: 700;
}

.search-use-grid h3 {
  margin: 54px 0 10px;
  font-size: 20px;
}

.search-use-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  text-wrap: pretty;
}

.search-workflow ol {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--text);
}

.search-workflow li {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 25px;
  padding: 25px;
}

.search-workflow li + li {
  border-top: 1px solid var(--line);
}

.search-workflow li > span {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 700;
}

.search-workflow h3 {
  margin: 0;
  font-size: 17px;
}

.search-workflow li p {
  max-width: 800px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.search-tips {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 70px;
}

.search-tips h2 {
  margin: 10px 0 14px;
  font-size: clamp(30px, 4vw, 48px);
}

.search-tips > div > p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.72;
}

.search-tips ul {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--text);
}

.search-tips li {
  position: relative;
  padding: 18px 22px 18px 48px;
  font-size: 13px;
  line-height: 1.6;
}

.search-tips li::before {
  position: absolute;
  top: 20px;
  left: 22px;
  content: "\2713";
  font-weight: 700;
}

.search-tips li + li {
  border-top: 1px solid var(--line);
}

.search-faq dl {
  margin: 0;
  border-top: 1px solid var(--line);
}

.search-faq dl > div {
  display: grid;
  grid-template-columns: minmax(240px, 0.72fr) minmax(0, 1.28fr);
  gap: 45px;
  padding: 23px 0;
  border-bottom: 1px solid var(--line);
}

.search-faq dt {
  font-size: 14px;
  font-weight: 700;
}

.search-faq dd {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.search-related {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 70px;
  padding: 70px 0;
  border-top: 1px solid var(--text);
}

.search-related h2 {
  max-width: 590px;
  margin: 10px 0 0;
  font-size: clamp(28px, 3.5vw, 42px);
}

.search-related nav {
  display: grid;
  border: 1px solid var(--text);
}

.search-related a {
  display: flex;
  justify-content: space-between;
  padding: 15px 18px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.search-related a + a {
  border-top: 1px solid var(--line);
}

.search-related a:hover,
.search-related a:focus-visible {
  background: var(--accent);
}

.search-cta {
  display: flex;
  gap: 40px;
  align-items: flex-end;
  justify-content: space-between;
  padding: 40px;
  background: var(--text);
  color: #fff;
}

.search-cta h2 {
  max-width: 760px;
  margin: 8px 0 10px;
  font-size: clamp(30px, 4vw, 48px);
}

.search-cta p {
  max-width: 680px;
  margin: 0;
  color: #deded7;
  font-size: 13px;
  line-height: 1.65;
}

.search-cta .primary-link {
  flex: 0 0 auto;
  color: var(--text);
  background: var(--accent);
  border-color: var(--accent);
}

/* Footer */
.global-footer {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 50px;
  padding: 42px 0 55px;
  border-top: 1px solid var(--text);
}

.footer-identity {
  display: block;
}

.footer-identity p {
  max-width: 320px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.footer-links {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 9px;
}

.footer-links > span {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

.footer-links a {
  color: var(--text);
  font-size: 11px;
  text-decoration: none;
}

.footer-links a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (max-width: 980px) {
  .site-header,
  main,
  .global-footer {
    width: min(100% - 28px, 720px);
  }

  .site-header {
    grid-template-columns: 1fr auto;
    padding: 15px 0 12px;
  }

  .brand-discipline {
    display: none;
  }

  .nav-toggle {
    display: block;
    grid-column: 2;
  }

  .main-nav {
    display: none;
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    align-items: stretch;
    flex-direction: column;
    gap: 0;
    margin-top: 12px;
    background: var(--paper);
    border: 1px solid var(--text);
  }

  .main-nav.open {
    display: flex;
  }

  .main-nav a {
    width: 100%;
    padding: 12px 14px;
  }

  .main-nav a + a {
    border-top: 1px solid var(--line);
  }

  .home-hero,
  .extension-hero,
  .search-hero {
    min-height: 0;
    grid-template-columns: 1fr;
    gap: 54px;
    padding: 64px 0 78px;
  }

  .search-section-heading,
  .search-tips,
  .search-related {
    grid-template-columns: 1fr;
    gap: 34px;
  }

  .search-use-grid {
    grid-template-columns: 1fr;
  }

  .search-use-grid article {
    min-height: auto;
  }

  .search-use-grid article + article {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .search-use-grid h3 {
    margin-top: 30px;
  }

  .equation-art {
    width: min(560px, 100%);
  }

  .product-card {
    min-height: 360px;
  }

  .page-intro {
    grid-template-columns: 1fr;
  }

  .page-intro .eyebrow,
  .page-intro h1,
  .page-intro > p:last-of-type {
    grid-column: 1;
  }

  .page-intro .tool-switch-link {
    grid-column: 1;
    grid-row: 4;
    margin-top: 18px;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .input-panel {
    border-right: 0;
    border-bottom: 0;
  }

  .trust-row {
    grid-template-columns: 1fr;
  }

  .trust-row > div {
    justify-content: flex-start;
  }

  .trust-row > div + div {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .extension-grid {
    grid-template-columns: 1fr 1fr;
  }

  .extension-grid article:nth-child(3) {
    border-left: 0;
  }

  .extension-grid article:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .story-chapter .timeline {
    grid-template-columns: 1fr;
  }

  .timeline article {
    min-height: 0;
  }

  .timeline article + article {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .story-current {
    grid-template-columns: 0.5fr 1.5fr;
  }

  .story-current p,
  .story-current .secondary-link {
    grid-column: 2;
  }

  .global-footer {
    grid-template-columns: 2fr 1fr 1fr;
  }

  .footer-identity {
    grid-column: 1 / -1;
  }

  .guide-choice-grid {
    grid-template-columns: 1fr;
  }

  .guide-choice-grid article {
    min-height: 0;
  }

  .guide-choice-grid article + article {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .guide-choice-grid p {
    margin-top: 24px;
  }

  .latex-reference-grid,
  .latex-mistakes {
    grid-template-columns: 1fr;
  }

  .latex-reference-grid article:nth-child(even),
  .latex-mistakes article:nth-child(even) {
    border-left: 0;
  }

  .latex-reference-grid article + article,
  .latex-mistakes article + article {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 820px) {
  .product-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  h1 {
    font-size: clamp(48px, 15vw, 72px);
  }

  .hero-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .search-hero h1 {
    font-size: clamp(42px, 14vw, 64px);
  }

  .search-actions,
  .search-cta {
    align-items: stretch;
    flex-direction: column;
  }

  .search-section {
    padding: 60px 0;
  }

  .search-workflow li {
    grid-template-columns: 45px 1fr;
    gap: 12px;
    padding: 20px;
  }

  .search-faq dl > div {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .search-cta {
    padding: 28px;
  }

  .primary-link,
  .secondary-link {
    justify-content: space-between;
  }

  .hero-proof {
    gap: 8px;
  }

  .hero-proof i {
    width: 12px;
  }

  .workflow-heading {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .student-guide-callout {
    align-items: flex-start;
    grid-template-columns: 1fr;
  }

  .student-guide-callout {
    flex-direction: column;
  }

  .page-intro {
    padding-top: 48px;
  }

  .page-intro .tool-switch-link {
    margin-top: 16px;
    white-space: normal;
  }

  .product-card {
    min-height: 0;
    padding: 25px;
  }

  .product-cards {
    grid-template-columns: 1fr;
  }

  .orbit-one {
    width: min(340px, 88vw);
    height: min(340px, 88vw);
  }

  .orbit-two {
    width: min(270px, 70vw);
    height: min(270px, 70vw);
  }

  .panel {
    padding: 0;
  }

  .workspace {
    gap: 28px;
    padding: 20px 20px 62px;
  }

  .result-actions {
    grid-template-columns: 1fr;
  }

  .crop-modal-backdrop {
    padding: 10px;
  }

  .crop-modal {
    padding: 18px;
  }

  .crop-stage {
    min-height: 210px;
    padding: 8px;
  }

  .crop-selection-row {
    align-items: flex-start;
    flex-direction: column;
    padding: 10px 0;
  }

  .crop-presets,
  .crop-modal-actions {
    width: 100%;
  }

  .crop-presets button {
    flex: 1;
  }

  .converter-help-button {
    left: 20px;
  }

  .converter-help-panel {
    right: 12px;
    bottom: 56px;
    left: 12px;
    width: auto;
  }

  .extension-grid {
    grid-template-columns: 1fr;
  }

  .extension-grid article {
    min-height: 0;
  }

  .extension-grid article + article,
  .extension-grid article:nth-child(3) {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .extension-grid h3 {
    margin-top: 36px;
  }

  .extension-note {
    align-items: flex-start;
    flex-direction: column;
  }

  .content-shortcuts {
    grid-template-columns: 1fr 1fr;
  }

  .content-shortcuts a + a {
    border-left: 0;
  }

  .content-shortcuts a:nth-child(even) {
    border-left: 1px solid var(--line);
  }

  .content-shortcuts a:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .content-section-heading,
  .guide-steps li,
  .guide-checklist,
  .content-cta,
  .content-row {
    grid-template-columns: 1fr;
  }

  .content-section-heading,
  .guide-steps li,
  .content-row {
    gap: 12px;
  }

  .content-row {
    padding: 28px 0 36px;
  }

  .content-row-label {
    grid-template-columns: 34px 1fr;
  }

  .content-cta {
    gap: 26px;
  }

  .story-current {
    grid-template-columns: 1fr;
  }

  .story-current p,
  .story-current .secondary-link {
    grid-column: 1;
  }

  .latex-build-heading,
  .guide-practice details > div {
    grid-template-columns: 1fr;
  }

  .guide-practice details > div {
    padding: 18px 20px 24px;
  }

  .guide-next-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .content-hero {
    padding-top: 64px;
  }

  .content-page {
    padding-bottom: 72px;
  }

  .global-footer {
    grid-template-columns: 1fr 1fr;
    gap: 36px 24px;
  }
}

/*
 * Touch refinements.
 *
 * Coarse pointers (phones and tablets) need three things the mouse layout does
 * not: hit areas that reach the 44px minimum, no 300 ms double-tap delay, and
 * text controls held at 16px. That last one matters most -- iOS Safari zooms the
 * whole page when a focused field's text is smaller than 16px, which leaves the
 * reader looking at a magnified fragment until they pinch back out.
 *
 * The selectors stay at single-element specificity so component rules (such as
 * the editor's 17px document title) keep their intended sizes.
 */
@media (pointer: coarse) {
  :where(a, button, [role="button"], summary, label, .drop-zone) {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  textarea,
  select,
  input:where(:not([type="checkbox"], [type="radio"], [type="file"])) {
    font-size: max(16px, 1em);
  }

  .nav-toggle,
  .converter-help-button,
  .editor-help-button,
  .icon-button,
  .crop-close,
  .math-modal header > button,
  .main-nav a,
  .footer-links a {
    min-width: 44px;
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
