.page-typography {
  --typography-reading-width: 72ch;
  --typography-sidebar-width: 17rem;
  --typography-correct: #087f5b;
  --typography-correct-bg: #e8f8f1;
  --typography-error: #b42318;
  --typography-error-bg: #fff1f0;
  overflow-x: clip;
}

[data-theme="dark"] .page-typography {
  --typography-correct: #5ee2b4;
  --typography-correct-bg: #12352d;
  --typography-error: #ffaaa2;
  --typography-error-bg: #3c2022;
}

.page-typography .footer {
  --text-secondary: #475569;
  --text-muted: #475569;
}

.page-typography .header {
  --text-secondary: #475569;
}

.page-typography .header .text-accent {
  color: #006b8f !important;
}

.page-typography .header .nav__dropdown-toggle {
  color: #334155;
}

[data-theme="dark"] .page-typography .footer {
  --text-secondary: #aab7c8;
  --text-muted: #aab7c8;
}

[data-theme="dark"] .page-typography .header {
  --text-secondary: #aab7c8;
}

[data-theme="dark"] .page-typography .header .text-accent {
  color: var(--color-accent-light) !important;
}

[data-theme="dark"] .page-typography .header .nav__dropdown-toggle {
  color: #cbd5e1;
}

.typography-hero {
  padding-bottom: var(--space-10);
}

.typography-hero__kicker {
  margin-bottom: var(--space-3);
  color: #006b8f;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
}

[data-theme="dark"] .typography-hero__kicker {
  color: var(--color-accent-light);
}

.typography-hero__title {
  max-width: 18ch;
  margin-inline: auto;
  font-size: var(--title-hero-long);
  text-wrap: balance;
}

.typography-hero__subtitle {
  max-width: 46rem;
  margin-inline: auto;
  text-wrap: balance;
}

.typography-hero__intro {
  max-width: 68ch;
  margin: var(--space-5) auto 0;
  color: var(--text-secondary);
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
  text-align: center;
}

.typography-specimen {
  position: relative;
  max-width: 50rem;
  margin: var(--space-10) auto 0;
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  background: var(--bg-card);
  box-shadow: var(--shadow-lg);
}

.typography-specimen__line {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  align-items: baseline;
  gap: var(--space-5);
  padding: var(--space-6) var(--space-8);
}

.typography-specimen__line + .typography-specimen__line {
  border-top: 1px solid var(--border-color);
}

.typography-specimen__line--before {
  background: var(--typography-error-bg);
}

.typography-specimen__line--after {
  background: var(--typography-correct-bg);
}

.typography-specimen__label {
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
}

.typography-specimen__line p {
  margin: 0;
  color: var(--text-primary);
  font-size: clamp(1.05rem, 0.92rem + 0.6vw, 1.35rem);
  line-height: 1.55;
}

.typography-specimen__line--before p {
  text-decoration-color: color-mix(in srgb, var(--typography-error) 45%, transparent);
  text-decoration-line: underline;
  text-decoration-style: wavy;
  text-underline-offset: 0.2em;
}

.typography-specimen__notes {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-8) var(--space-5);
  margin: 0;
  border-top: 1px solid var(--border-color);
  list-style: none;
}

.typography-specimen__notes li {
  padding: var(--space-1) var(--space-3);
  margin: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: var(--text-xs);
}

.typography-hero__actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  margin-top: var(--space-6);
}

.typography-hero__updated {
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.typography-mobile-toc {
  display: none;
}

.typography-finder {
  padding-bottom: var(--space-12);
}

.typography-finder .container {
  padding-block: var(--space-8);
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.typography-finder__heading {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  align-items: baseline;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}

.typography-finder__heading h2,
.typography-finder__heading p {
  margin: 0;
}

.typography-finder__heading h2 {
  font-size: var(--title-card);
}

.typography-finder__heading p {
  color: var(--text-muted);
}

.typography-finder__links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: var(--space-8);
}

.typography-finder__links a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 2.75rem;
  padding-block: var(--space-2);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  font-weight: var(--font-semibold);
  text-decoration: none;
}

.typography-finder__links a::after {
  content: "→";
  color: #006b8f;
}

[data-theme="dark"] .typography-finder__links a::after {
  color: var(--color-accent-light);
}

.typography-layout {
  display: grid;
  grid-template-columns: var(--typography-sidebar-width) minmax(0, 1fr);
  align-items: start;
  gap: clamp(2rem, 2vw + 1rem, 4.5rem);
  padding-bottom: var(--space-16);
}

.typography-sidebar {
  position: sticky;
  top: calc(var(--header-height) + var(--space-5));
  max-height: calc(100vh - var(--header-height) - var(--space-10));
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.typography-toc {
  padding-right: var(--space-4);
  border-right: 1px solid var(--border-color);
}

.typography-toc__title {
  margin-bottom: var(--space-4);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
}

.typography-toc ol {
  padding: 0;
  margin: 0;
  list-style: none;
}

.typography-toc li {
  margin: 0;
}

.typography-toc a {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  text-decoration: none;
}

.typography-toc a:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.typography-toc a[aria-current="location"] {
  background: color-mix(in srgb, var(--color-accent) 13%, transparent);
  color: var(--text-primary);
  font-weight: var(--font-semibold);
}

.typography-toc .typography-toc__rules {
  display: none;
  padding: 0 0 var(--space-2) var(--space-3);
}

.typography-toc > ol > li:has(> a[aria-current="location"]) > .typography-toc__rules,
.typography-toc > ol > li:focus-within > .typography-toc__rules {
  display: block;
}

.typography-toc .typography-toc__rules a {
  padding-block: var(--space-1);
  font-size: var(--text-xs);
}

.typography-toc__print {
  margin: var(--space-4) var(--space-3) 0;
  color: #006b8f;
  font-size: var(--text-sm);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

[data-theme="dark"] .typography-toc__print {
  color: var(--color-accent-light);
}

.typography-article {
  min-width: 0;
  max-width: var(--typography-reading-width);
}

.typography-article a,
.typography-review-meta a,
.typography-hero__updated {
  color: #006b8f;
  text-decoration: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
}

.typography-rule code {
  color: #334155;
}

[data-theme="dark"] .typography-article a,
[data-theme="dark"] .typography-review-meta a,
[data-theme="dark"] .typography-hero__updated {
  color: var(--color-accent-light);
}

[data-theme="dark"] .typography-rule code {
  color: var(--text-primary);
}

.typography-chapter {
  scroll-margin-top: calc(var(--header-height) + var(--space-6));
  padding: var(--space-16) 0;
  border-top: 1px solid var(--border-color);
}

.typography-chapter:first-child {
  padding-top: 0;
  border-top: 0;
}

.typography-chapter__header {
  margin-bottom: var(--space-6);
}

.typography-chapter__header h2 {
  max-width: 25ch;
  margin-bottom: var(--space-4);
  font-size: var(--title-section);
  text-wrap: balance;
}

.typography-chapter__header p {
  max-width: 66ch;
  margin: 0;
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
}

.typography-chapter__index {
  padding: var(--space-5) 0;
  margin-bottom: var(--space-8);
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.typography-chapter__index > p {
  margin-bottom: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
}

.typography-chapter__index ol {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2) var(--space-7);
  padding: 0;
  margin: 0;
  list-style-position: inside;
}

.typography-chapter__index li {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.typography-chapter__index a {
  color: var(--text-secondary);
  text-decoration: none;
}

.typography-chapter__index a:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

.typography-rule + .typography-rule {
  margin-top: var(--space-8);
}

.typography-rule {
  scroll-margin-top: calc(var(--header-height) + var(--space-6));
  padding-top: var(--space-2);
}

.typography-rule h3 {
  margin-bottom: var(--space-3);
  font-size: var(--title-card);
}

.typography-rule h3 a {
  color: inherit;
  text-decoration: none;
}

.typography-rule h3 a:hover::after,
.typography-rule h3 a:focus-visible::after {
  content: " #";
  color: var(--text-muted);
  font-weight: var(--font-normal);
}

.typography-rule__summary {
  max-width: 68ch;
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

.typography-rule__summary p:last-child,
.typography-advanced__body p:last-child,
.typography-advanced__body ul:last-child {
  margin-bottom: 0;
}

.typography-example-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.typography-example {
  min-width: 0;
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

.typography-example--bad {
  background: var(--typography-error-bg);
}

.typography-example--good {
  background: var(--typography-correct-bg);
}

.typography-example > span {
  display: block;
  margin-bottom: var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
}

.typography-example p {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text-primary);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
}

.typography-note {
  padding: var(--space-4) 0;
  margin: var(--space-5) 0 0;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.typography-advanced {
  margin-top: var(--space-5);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
}

.typography-advanced summary {
  padding: var(--space-4) var(--space-5);
  color: var(--text-primary);
  font-weight: var(--font-semibold);
  cursor: pointer;
}

.typography-advanced__body {
  padding: 0 var(--space-5) var(--space-5);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

.typography-copy-palette {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-10);
}

.typography-copy-palette__heading {
  grid-column: 1 / -1;
  margin-bottom: var(--space-1);
}

.typography-copy-palette__heading h4 {
  margin-bottom: var(--space-1);
  font-size: var(--text-base);
}

.typography-copy-palette__heading p {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.typography-copy {
  display: inline-grid;
  grid-template-columns: minmax(2.5rem, auto) auto;
  align-items: center;
  min-height: 3rem;
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), background-color var(--transition-fast), transform var(--transition-fast);
}

.typography-copy:hover {
  border-color: var(--color-accent-dark);
  background: var(--bg-secondary);
  transform: translateY(-1px);
}

.typography-copy.is-copied {
  border-color: var(--typography-correct);
  background: var(--typography-correct-bg);
}

.typography-copy__glyph {
  display: grid;
  min-height: 100%;
  padding: var(--space-2) var(--space-3);
  place-items: center;
  border-right: 1px solid var(--border-color);
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
}

.typography-copy__name {
  padding: var(--space-2) var(--space-3);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.typography-faq__item + .typography-faq__item {
  margin-top: var(--space-3);
}

.typography-sources__list {
  padding-left: var(--space-5);
}

.typography-sources__list li {
  margin-bottom: var(--space-4);
  line-height: var(--leading-relaxed);
}

.typography-review-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-top: var(--space-6);
  margin-top: var(--space-8);
  border-top: 1px solid var(--border-color);
}

.typography-review-meta p {
  margin: 0;
  font-size: var(--text-sm);
}

.typography-review-meta a {
  font-size: var(--text-sm);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.typography-final {
  padding-top: 0;
}

.typography-final__panel {
  padding: clamp(2rem, 5vw, 3.25rem);
  border: 1px solid #28445d;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, #102a3a, #18273a);
  color: #f8fafc;
  text-align: center;
}

.typography-final__panel h2 {
  color: inherit;
}

.typography-final__sentence {
  max-width: 42rem;
  padding: var(--space-5) 0;
  margin: var(--space-6) auto;
  border-top: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  color: inherit;
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
}

.typography-final__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
}

.typography-final__actions > a.btn[href="/download"] {
  background: linear-gradient(135deg, var(--color-cta), var(--color-cta-dark));
  box-shadow: var(--shadow-md), 0 0 20px rgba(0, 200, 255, 0.3);
}

.typography-final__actions > a.btn[href="/download"]:hover {
  background: linear-gradient(135deg, var(--color-cta-light), var(--color-cta));
  box-shadow: var(--shadow-lg), 0 0 30px rgba(0, 200, 255, 0.4);
}

.typography-copy-status {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  z-index: var(--z-sticky);
  max-width: min(22rem, calc(100vw - 2rem));
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--typography-correct);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.5rem);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.typography-copy-status.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.typography-print-url {
  display: none;
}

.typography-mobile-bar {
  display: none;
}

@media (max-width: 960px) {
  .page-typography {
    padding-bottom: 4.5rem;
  }

  .typography-mobile-toc {
    display: block;
  }

  .typography-layout {
    display: block;
    max-width: var(--max-width-narrow);
  }

  .typography-sidebar {
    display: none;
  }

  .typography-toc-mobile {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
  }

  .typography-toc-mobile summary {
    padding: var(--space-4) var(--space-5);
    color: var(--text-primary);
    font-weight: var(--font-semibold);
    cursor: pointer;
  }

  .typography-toc-mobile ol {
    padding: 0 var(--space-6) var(--space-5) 2.75rem;
    margin: 0;
  }

  .typography-toc-mobile a {
    text-decoration: underline;
    text-underline-offset: 0.18em;
  }

  .typography-mobile-bar {
    position: fixed;
    right: var(--space-3);
    bottom: var(--space-3);
    left: var(--space-3);
    z-index: var(--z-sticky);
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    min-height: 3.25rem;
    overflow: hidden;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    box-shadow: var(--shadow-lg);
  }

  .typography-mobile-bar button,
  .typography-mobile-bar a {
    min-height: 3.25rem;
    padding-inline: var(--space-4);
    color: #006b8f;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
  }

  [data-theme="dark"] .typography-mobile-bar button,
  [data-theme="dark"] .typography-mobile-bar a {
    color: var(--color-accent-light);
  }

  .typography-mobile-bar span {
    min-width: 0;
    overflow: hidden;
    color: var(--text-secondary);
    font-size: var(--text-xs);
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 640px) {
  .typography-hero {
    padding-bottom: var(--space-8);
  }

  .typography-hero__intro {
    text-align: left;
  }

  .typography-specimen {
    margin-top: var(--space-8);
  }

  .typography-specimen__line {
    display: block;
    padding: var(--space-5);
  }

  .typography-specimen__label {
    display: block;
    margin-bottom: var(--space-2);
  }

  .typography-specimen__notes {
    padding: var(--space-4) var(--space-5);
  }

  .typography-hero__actions {
    align-items: stretch;
    flex-direction: column;
    text-align: center;
  }

  .typography-finder__heading {
    display: block;
  }

  .typography-finder__heading h2 {
    margin-bottom: var(--space-2);
  }

  .typography-finder__links,
  .typography-chapter__index ol {
    grid-template-columns: 1fr;
  }

  .typography-chapter {
    padding: var(--space-12) 0;
  }

  .typography-chapter__header {
    margin-bottom: var(--space-8);
  }

  .typography-example-pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
  }

  .typography-example {
    padding: var(--space-3);
  }

  .typography-example p {
    font-size: var(--text-sm);
  }

  .typography-copy-palette {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .typography-copy {
    grid-template-columns: 2.5rem minmax(0, 1fr);
    text-align: left;
  }

  .typography-copy__name {
    overflow-wrap: anywhere;
  }

  .typography-final__actions {
    flex-direction: column;
  }

  .typography-final__actions .btn {
    width: 100%;
  }
}

@media print {
  @page {
    size: A4;
    margin: 16mm 15mm 18mm;
  }

  .page-typography {
    --typography-reading-width: none;
  }

  .typography-hero {
    padding: 0 0 10mm;
  }

  .typography-hero__kicker,
  .typography-hero__actions,
    .typography-mobile-toc,
    .typography-sidebar,
    .typography-finder,
    .typography-chapter__index,
    .typography-mobile-bar,
  .typography-copy-palette,
  .typography-final,
  .typography-copy-status,
  .typography-review-meta a {
    display: none !important;
  }

  .typography-hero__title,
  .typography-hero__subtitle,
  .typography-hero__intro {
    max-width: none;
    color: #000 !important;
  }

  .typography-hero__title {
    font-size: 25pt;
  }

  .typography-specimen {
    margin-top: 8mm;
    border-color: #777;
    box-shadow: none;
    break-inside: avoid;
  }

  .typography-specimen__line,
  .typography-specimen__notes,
  .typography-example,
  .typography-advanced {
    background: #fff !important;
    border-color: #aaa !important;
  }

  .typography-layout {
    display: block;
    padding: 0;
  }

  .typography-chapter__header {
    display: block !important;
  }

  .typography-article {
    max-width: none;
  }

  .typography-chapter {
    padding: 9mm 0 0;
    border-top-color: #999;
  }

  .typography-chapter__header,
  .typography-rule,
  .typography-example-pair,
  .typography-advanced {
    break-inside: avoid;
  }

  .typography-chapter__header h2,
  .typography-rule h3,
  .typography-rule__summary,
  .typography-example p,
  .typography-note,
  .typography-advanced__body,
  .typography-sources__list li,
  .typography-review-meta p {
    color: #000 !important;
  }

  .typography-advanced[open] .typography-advanced__body {
    display: block !important;
  }

  .typography-print-url {
    display: block;
    margin: 10mm 0 0;
    color: #333;
    font-size: 9pt;
  }

  a[href^="http"]::after {
    content: none;
  }
}
