.correspondence-page {
  max-width: 1080px;
  padding-bottom: 4rem;
}

nav a[aria-current="page"] {
  color: var(--accent);
  font-weight: 650;
}

.directory {
  /* Reset the shared header-nav flex treatment: this semantic navigation is
     the page's full-width visual directory, not a row of header links. */
  display: block;
  color: var(--text);
  font-size: 1rem;
  padding: clamp(3rem, 7vw, 5.5rem) 0 clamp(2.4rem, 5vw, 4rem);
}

.directory h1 {
  max-width: 900px;
  margin-bottom: 0.6rem;
}

.directory-legend {
  max-width: 760px;
  margin: 0 0 0.8rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.notation-caveat {
  max-width: 760px;
  margin: 0 0 0.8rem;
  padding: 0.72rem 0.82rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: var(--surface);
}

.notation-caveat h2 {
  margin: 0 0 0.22rem;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
}

.notation-caveat p {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.5;
}

.directory-census {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  max-width: 760px;
  margin: 0 0 clamp(1.6rem, 4vw, 2.4rem);
  padding: 0;
  border-left: 3px solid var(--accent);
  background: var(--line);
  color: var(--muted);
  font-size: 0.78rem;
}

.directory-census p {
  display: grid;
  align-content: start;
  gap: 0.18rem;
  margin: 0;
  padding: 0.68rem 0.78rem;
  background: var(--surface);
}

.directory-census strong {
  color: var(--text);
  font-size: 0.72rem;
  line-height: 1.25;
}

.directory-census p > span {
  line-height: 1.35;
}

.census-number {
  display: block;
  margin-bottom: 0.08rem;
  color: var(--accent);
  font-size: 1.35rem;
  font-weight: 720;
  letter-spacing: -0.035em;
  line-height: 1;
}

.provenance {
  padding: clamp(2.5rem, 5vw, 4.5rem) 0;
  border-top: 1px solid var(--line);
}

.provenance h2 {
  max-width: 800px;
  margin-bottom: 1.4rem;
  font-size: clamp(1.65rem, 3vw, 2.45rem);
  font-weight: 570;
  line-height: 1.12;
  letter-spacing: -0.035em;
}

.directory-families {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border-block: 1px solid var(--line);
  background: var(--line);
}

.directory-family {
  display: grid;
  grid-template-columns: minmax(6.4rem, 0.18fr) minmax(0, 0.82fr);
  gap: 1.25rem;
  padding: 0.72rem 0.8rem;
  background: var(--surface);
}

.directory-family h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.1;
}

.directory-family h2 a {
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  text-decoration: none;
}

.directory-family h2 a:hover,
.directory-family h2 a:focus-visible {
  color: var(--accent);
}

.directory-family h2 > span {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.directory-groups {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.48rem;
  min-width: 0;
  padding-bottom: 0.12rem;
}

.directory-group {
  display: grid;
  flex: 0 0 auto;
  gap: 0.28rem;
  min-width: 5.6rem;
  padding: 0.34rem 0.4rem 0.42rem;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text);
  text-decoration: none;
}

.directory-group:hover,
.directory-group:focus-visible {
  border-color: var(--accent);
  background: var(--background);
  color: var(--accent);
}

.directory-signature {
  justify-self: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.1;
  white-space: nowrap;
}

.clockwork-disambiguator {
  color: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 650;
}

.clockwork-disambiguator sub,
.clockwork-disambiguator sup {
  font-size: 0.66em;
  line-height: 0;
}

.clockwork-disambiguator--directory {
  justify-self: center;
  font-size: 0.72rem;
  line-height: 1;
}

.directory-palette {
  display: flex;
  width: 100%;
  min-width: 4rem;
  height: 1.15rem;
  overflow: hidden;
  border: 1px solid rgb(35 45 41 / 0.42);
  border-radius: 2px;
}

.directory-palette span {
  flex: 1 1 0;
  background: var(--directory-colour);
}

.directory-group-id {
  justify-self: center;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.58rem;
  line-height: 1;
}

.correspondence-atlas {
  border-top: 1px solid var(--line);
}

.wallpaper-family {
  padding: clamp(3rem, 7vw, 6rem) 0;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 1rem;
}

.wallpaper-family.is-empty {
  padding-block: clamp(2.2rem, 5vw, 3.5rem);
  background: linear-gradient(90deg, transparent, rgb(50 69 63 / 0.025), transparent);
}

.family-header {
  max-width: 900px;
  margin-bottom: 1.6rem;
}

.family-header h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.65rem;
  margin: 0 0 0.8rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 3.25rem);
  font-weight: 570;
  line-height: 1;
  letter-spacing: -0.025em;
}

.family-count {
  color: var(--muted);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.28em;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.family-summary {
  max-width: 760px;
  margin-bottom: 0.45rem;
  color: #37413d;
  font-size: 1.05rem;
}

.trivial-product {
  max-width: 820px;
  margin-top: clamp(1.8rem, 4vw, 3rem);
  padding: 0.8rem 1rem;
  border: 1px solid #d7dbd9;
  border-left: 4px solid #c3c9c6;
  border-radius: 6px;
  background: #f1f2f1;
  color: #7b837f;
  font-size: 0.78rem;
  scroll-margin-top: 1rem;
}

.trivial-product p {
  margin: 0;
}

.trivial-product strong {
  color: #666e6a;
}

.trivial-fibrifold {
  display: grid;
  grid-template-columns: minmax(9.5rem, 0.82fr) minmax(0, 1.18fr);
  gap: 0.65rem;
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid #d7dbd9;
}

.clockwork-tabs {
  min-width: 0;
}

.clockwork-tabbar {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: flex-start;
  gap: 0.35rem;
  padding: 0 0.15rem;
  overflow-x: auto;
  scrollbar-width: thin;
}

.clockwork-tab {
  display: inline-flex;
  min-width: max-content;
  padding: 0.4rem 0.72rem 0.36rem;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: var(--surface);
  color: var(--muted);
  flex-direction: column;
  text-decoration: none;
}

.clockwork-tab:hover,
.clockwork-tab:focus-visible {
  color: var(--accent);
}

.clockwork-tab[aria-selected="true"] {
  background: var(--background);
  color: var(--text);
  box-shadow: 0 2px 0 var(--background);
}

.tab-signature {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.02rem;
  font-weight: 650;
  line-height: 1.15;
}

.clockwork-disambiguator--tab {
  margin-top: 0.12rem;
  font-size: 0.7rem;
  line-height: 1;
}

.tab-meta {
  margin-top: 0.16rem;
  font-size: 0.58rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

.correspondence-item[hidden],
.correspondence-entry[hidden] {
  display: none;
}

.correspondence-entry {
  padding: clamp(1.4rem, 4vw, 2.5rem);
  border: 1px solid var(--line);
  border-radius: 0 8px 8px 8px;
  background: var(--background);
  box-shadow: 0 12px 28px rgb(35 45 41 / 0.05);
  scroll-margin-top: 1rem;
}

.entry-header {
  margin-bottom: 1.5rem;
}

.entry-header h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.85rem, 4vw, 3rem);
  font-weight: 570;
  line-height: 1;
  letter-spacing: -0.025em;
}

.clockwork-disambiguator--heading {
  display: block;
  margin-top: 0.42rem;
  font-size: 1rem;
  line-height: 1.15;
}

.clockwork-disambiguator--heading::before {
  content: "clockwork ";
  color: var(--muted);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.68rem;
  font-weight: 550;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.orbifold-star {
  font-family: "STIX Two Math", "Cambria Math", "Times New Roman", serif;
  font-size: 1em;
  font-style: normal;
  font-weight: inherit;
  letter-spacing: 0;
  vertical-align: baseline;
}

.book-color-signature sup,
.tab-signature sup {
  font-size: 0.56em;
  line-height: 0;
  vertical-align: 0.68em;
}

.group-id {
  margin-left: 0.35rem;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0;
  vertical-align: middle;
}

.entry-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: start;
}

.entry-visuals {
  display: grid;
  min-width: 0;
  gap: 1rem;
}

.colour-plate,
.clockwork-film {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #f7f4ec;
}

.clockwork-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 12 / 7;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(0, 111, 99, 0.035), transparent 45%),
    #faf8f1;
}

.clockwork-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.film-status {
  position: absolute;
  inset: 50% auto auto 50%;
  width: min(80%, 22rem);
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
  transform: translate(-50%, -50%);
}

.film-status[hidden] {
  display: none;
}

.clockwork-stage[data-state="error"] .film-status {
  color: #8c382e;
}

.clockwork-film .animation-controls {
  margin: 0;
  padding: 0.62rem 0.72rem;
  border-top: 1px solid var(--line);
  background: var(--background);
}

.colour-plate figcaption {
  margin: 0;
}

.colour-plate img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 12 / 7;
  object-fit: cover;
}

.colour-plate figcaption {
  padding: 0.8rem 0.9rem 0.85rem;
  border-top: 1px solid var(--line);
  background: var(--background);
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.colour-key {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
  color: #37413d;
  font-size: 0.68rem;
  letter-spacing: 0;
  text-transform: none;
}

.colour-key li {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
}

.swatch {
  width: 0.76rem;
  height: 0.76rem;
  flex: none;
  border: 1px solid #26332f;
  border-radius: 2px;
  background: var(--swatch);
}

.entry-copy {
  min-width: 0;
  color: #37413d;
}

.other-names {
  margin: 0;
}

.other-names h4 {
  margin: 0 0 0.22rem;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
}

.other-names ul {
  margin: 0;
  padding: 0;
  border-block: 1px solid var(--line);
  list-style: none;
}

.other-names li {
  display: grid;
  grid-template-columns: minmax(9.5rem, 0.82fr) minmax(0, 1.18fr);
  gap: 0.65rem;
  padding: 0.42rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.76rem;
}

.other-names li:last-child {
  border-bottom: 0;
}

.term-help {
  position: relative;
  min-width: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 550;
}

.term-help-label {
  position: relative;
  display: inline-block;
  width: fit-content;
  padding-right: 0.72rem;
  border-bottom: 1px dotted currentColor;
  cursor: help;
}

.term-help-label::after {
  position: absolute;
  right: 0.12rem;
  bottom: 0;
  content: "?";
  color: var(--accent);
  font-size: 0.82em;
  font-weight: 750;
}

.term-help-copy {
  position: absolute;
  z-index: 30;
  top: calc(100% + 0.35rem);
  left: 0;
  display: none;
  width: min(22rem, calc(100vw - 3rem));
  padding: 0.62rem 0.7rem;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--surface-raised, #fff);
  box-shadow: 0 0.55rem 1.35rem rgb(26 39 34 / 0.16);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 450;
  line-height: 1.42;
  pointer-events: none;
}

.term-help:hover .term-help-copy {
  display: block;
}

.other-names a {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 620;
  text-decoration-style: dotted;
  text-underline-offset: 0.16em;
}

.other-name-value {
  display: grid;
  gap: 0.16rem;
}

.other-name-value code {
  color: var(--muted);
  font-size: 0.68rem;
}

.fibrifold-name {
  color: var(--text);
  font-family: "STIX Two Math", "Cambria Math", Georgia, "Times New Roman", serif;
  font-size: 0.96rem;
  font-weight: 650;
  line-height: 1.15;
  white-space: nowrap;
}

.fibrifold-orientation-note {
  max-width: 24rem;
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.35;
}

.book-page-link {
  font-weight: 620;
  text-decoration-style: dotted;
  text-underline-offset: 0.16em;
}

a[data-book-excerpt] {
  display: inline-block;
  cursor: zoom-in;
}

a[data-book-excerpt]::after {
  content: "  ◫";
  color: var(--accent);
  font-size: 0.86em;
}

.group-presentation {
  margin: 0 0 1.25rem;
}

.group-presentation h4 {
  margin: 0 0 0.22rem;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
}

.group-presentation table {
  width: 100%;
  border-collapse: collapse;
  border-block: 1px solid var(--line);
  font-size: 0.76rem;
}

.group-presentation th,
.group-presentation td {
  padding: 0.34rem 0.42rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.group-presentation th {
  color: var(--text);
  font-weight: 500;
}

.group-presentation td:last-child {
  width: 7.2rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.generator-key {
  display: inline-block;
  min-width: 1.45rem;
  margin-right: 0.36rem;
  color: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  line-height: 1;
}

.group-presentation tbody tr:last-child th,
.group-presentation tbody tr:last-child td {
  border-bottom: 0;
}

.presentation-relations {
  display: flex;
  gap: 0.6rem;
  margin: 0.5rem 0 0;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.8rem;
  line-height: 1.45;
}

.presentation-relations strong {
  flex: 0 0 auto;
  color: var(--muted);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.025em;
}

.presentation-relations span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.provenance {
  max-width: 880px;
}

.provenance p {
  max-width: 800px;
  color: #37413d;
}

.provenance code {
  overflow-wrap: anywhere;
}

.correspondence-page footer {
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

.book-excerpt-dialog {
  position: fixed;
  inset: 0;
  z-index: 1000;
  width: min(90rem, calc(100vw - 1rem));
  max-width: none;
  max-height: 94dvh;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid #706d65;
  border-radius: 6px;
  background: #faf8f2;
  color: var(--text);
  box-shadow: 0 22px 70px rgb(20 24 22 / 0.34);
}

.book-excerpt-dialog:not([open]) {
  display: none;
}

.book-excerpt-dialog.is-fallback-open {
  display: block;
  box-shadow:
    0 0 0 100vmax rgb(19 25 23 / 0.76),
    0 22px 70px rgb(20 24 22 / 0.34);
}

.book-dialog-open {
  overflow: hidden;
}

.book-excerpt-dialog::backdrop {
  background: rgb(19 25 23 / 0.76);
  backdrop-filter: blur(2px);
}

.book-excerpt-panel {
  display: flex;
  max-height: 94dvh;
  margin: 0;
  flex-direction: column;
}

.book-excerpt-header {
  position: relative;
  padding: 1.25rem 4.5rem 1rem 1.35rem;
  border-bottom: 1px solid var(--line);
  background: var(--background);
}

.book-excerpt-header .overline {
  margin: 0 0 0.28rem;
}

.book-excerpt-header h2 {
  margin: 0;
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  line-height: 1.15;
}

.book-excerpt-header p:last-child {
  max-width: 48rem;
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.book-excerpt-close {
  position: absolute;
  top: 0.85rem;
  right: 0.9rem;
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--control-line);
  border-radius: 50%;
  background: var(--surface-raised);
  color: var(--text);
  font: 400 1.65rem/1 ui-sans-serif, sans-serif;
  cursor: pointer;
}

.book-excerpt-close:hover,
.book-excerpt-close:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.book-excerpt-media {
  position: relative;
  display: grid;
  min-height: 8rem;
  min-width: 0;
  max-height: min(70dvh, 60rem);
  flex: 0 1 auto;
  overflow: auto;
  place-items: center;
  background: #e8e4da;
}

.book-excerpt-media img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: min(70dvh, 60rem);
  height: auto;
  margin: auto;
  object-fit: contain;
}

.book-excerpt-media[data-zoom="actual"] {
  place-items: start;
}

.book-excerpt-media[data-zoom="actual"] img {
  max-width: none;
  max-height: none;
  margin: 0;
}

.book-excerpt-media:not([data-state="ready"]) img {
  opacity: 0;
}

.book-excerpt-status {
  position: absolute;
  inset: 0;
  display: grid;
  margin: 0;
  padding: 1.5rem;
  place-items: center;
  color: #454c48;
  font-size: 0.88rem;
  text-align: center;
}

.book-excerpt-status[hidden] {
  display: none;
}

.book-excerpt-media[data-state="error"] .book-excerpt-status {
  color: #8b3626;
}

.book-excerpt-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 0.85rem 1.35rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--background);
}

.book-excerpt-footer p {
  max-width: 43rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.book-excerpt-source {
  flex: 0 0 auto;
  font-size: 0.8rem;
  font-weight: 650;
}

.book-excerpt-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.85rem;
}

.book-excerpt-zoom {
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--control-line);
  border-radius: 3px;
  background: var(--surface-raised);
  color: var(--text);
  font: 650 0.75rem/1 ui-sans-serif, sans-serif;
  cursor: pointer;
}

.book-excerpt-zoom:hover,
.book-excerpt-zoom:focus-visible,
.book-excerpt-zoom[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

@media (max-width: 900px) {
  .entry-grid {
    grid-template-columns: 1fr;
  }

  .entry-copy {
    max-width: 760px;
  }
}

@media (max-width: 700px) {
  .directory-census {
    grid-template-columns: 1fr;
  }

  .book-excerpt-dialog {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .book-excerpt-panel {
    height: 100dvh;
    max-height: 100dvh;
  }

  .book-excerpt-media {
    max-height: none;
    flex: 1 1 auto;
  }

  .book-excerpt-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.55rem;
  }

  .book-excerpt-actions {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 430px) {
  .directory-family {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .directory-family h2 > span {
    display: inline;
    margin-left: 0.38rem;
  }

  .directory-groups {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .other-names li {
    grid-template-columns: 1fr;
    gap: 0.14rem;
  }

  .trivial-fibrifold {
    grid-template-columns: 1fr;
    gap: 0.14rem;
  }

  .group-presentation td:last-child {
    width: 5.6rem;
    white-space: normal;
  }

}

@media print {
  .site-header,
  .directory,
  .clockwork-film,
  .book-excerpt-dialog,
  footer {
    display: none;
  }

  .correspondence-entry {
    break-before: page;
  }

  .term-help-copy,
  .term-help-label::after {
    display: none !important;
  }
}
