@import url("/assets/reader-typography.css");

@font-face {
  font-family: "Anthropic Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/fonts/AnthropicSans-Text-Medium.otf") format("opentype");
}

@font-face {
  font-family: "Anthropic Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/fonts/AnthropicSans-Text-Semibold.otf") format("opentype");
}

:root {
  color-scheme: light;
  --paper: #fbfaf7;
  --ink: #1a1a1a;
  --muted: #444;
  --faint: #6f6f6f;
  --rule: #cfcabb;
  --accent: #333;
  --wash: #f3f0e8;
  --measure: 42rem;
  --body-measure: var(--reader-body-measure);
  --serif: var(--reader-font-family);
  --sans: "Anthropic Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #14140f;
  --ink: #e9e5d8;
  --muted: #b3ad9c;
  --faint: #8e8879;
  --rule: #3a382f;
  --accent: #e9e5d8;
  --wash: #1d1c16;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--reader-body-size);
  font-weight: var(--reader-body-weight);
  line-height: var(--reader-body-line-height);
  letter-spacing: var(--reader-body-letter-spacing);
  word-spacing: var(--reader-body-word-spacing);
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-color: var(--faint);
}

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

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.5rem 0.8rem;
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: translateY(0);
}

.running-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 1.25rem;
  align-items: center;
  min-height: 3.25rem;
  padding: 0.55rem 1.4rem;
  border-bottom: 1px solid var(--rule);
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(10px);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.library-back,
.volume-step {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--sans);
  font-weight: 600;
  text-decoration: none;
}

.library-back {
  padding: 0.42rem 0.65rem;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: var(--wash);
}

.library-back:hover,
.volume-step:hover {
  border-color: var(--faint);
}

.back-label-short {
  display: none;
}

.running-title {
  overflow: hidden;
  color: var(--faint);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-track {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  overflow: hidden;
}

.progress-track span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--ink);
  transform: scaleX(0);
  transform-origin: left;
}

.toc-button {
  display: none;
  border: 0;
  background: transparent;
  color: inherit;
  font-family: var(--sans);
  font-size: inherit;
  font-weight: 600;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.document-search-toggle,
.theme-toggle {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  min-height: 2rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font-family: var(--sans);
  font-size: inherit;
  font-weight: 600;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.document-search-toggle:hover,
.document-search-toggle[aria-expanded="true"] {
  background: var(--wash);
}

.theme-toggle:hover {
  background: var(--wash);
}

.document-search-toggle svg,
.document-search-panel svg,
.theme-toggle svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.theme-icon {
  display: none;
}

.theme-toggle[data-theme-next="dark"] .theme-icon-moon,
.theme-toggle[data-theme-next="light"] .theme-icon-sun {
  display: block;
}

.theme-toggle-floating {
  position: fixed;
  z-index: 30;
  top: 1rem;
  right: 1rem;
  border-color: var(--rule);
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(10px);
}

.header-navigation {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  justify-content: flex-end;
}

.volume-step,
.toc-button {
  min-height: 2rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid transparent;
  border-radius: 6px;
}

.volume-step:hover,
.toc-button:hover {
  background: var(--wash);
}

.document-search-panel {
  position: fixed;
  z-index: 30;
  top: 4rem;
  right: 1.4rem;
  width: min(36rem, calc(100vw - 2.8rem));
  padding: 0.85rem;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: 0 16px 50px rgb(30 28 24 / 0.16);
  font-family: var(--sans);
}

.document-search-panel[hidden] {
  display: none;
}

.document-search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.55rem 0.75rem;
  align-items: center;
}

.document-search-form > label {
  grid-column: 1 / -1;
  color: var(--faint);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.document-search-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: center;
  min-height: 2.65rem;
  padding: 0 0.75rem;
  border: 1px solid var(--faint);
  border-radius: 7px;
  background: #fff;
}

.document-search-field:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ink) 14%, transparent);
}

.document-search-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: 500 0.92rem/1.2 var(--sans);
}

.document-search-field input::-webkit-search-cancel-button {
  display: none;
}

.document-search-field kbd {
  padding: 0.18rem 0.32rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--wash);
  color: var(--faint);
  font: 600 0.65rem/1 var(--sans);
}

.document-search-status {
  min-width: 4.7rem;
  color: var(--faint);
  font-size: 0.78rem;
  text-align: right;
  white-space: nowrap;
}

.document-search-actions {
  display: flex;
  gap: 0.15rem;
}

.document-search-actions button {
  display: inline-grid;
  width: 2.45rem;
  height: 2.45rem;
  padding: 0;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.document-search-actions button:hover:not(:disabled) {
  border-color: var(--rule);
  background: var(--wash);
}

.document-search-actions button:disabled {
  color: var(--rule);
  cursor: default;
}

.reader-search-match {
  padding: 0.02em 0.08em;
  border-radius: 0.12em;
  background: #f7dfa1;
  color: inherit;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.reader-search-match.is-current {
  background: #f0a94a;
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px #a65d00;
}

.reader-grid {
  display: grid;
  grid-template-columns: minmax(13rem, 18rem) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 6rem);
  width: min(100% - 3rem, 92rem);
  margin: 0 auto;
}

.toc-rail {
  position: sticky;
  top: 4.75rem;
  align-self: start;
  max-height: calc(100vh - 6rem);
  padding: 2rem 0 3rem;
  overflow: auto;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.42;
  scrollbar-width: thin;
}

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

.toc-list li + li {
  margin-top: 0.55rem;
}

.toc-list .toc-level-3 {
  padding-left: 0.9rem;
  color: var(--faint);
  font-size: 0.94em;
}

.toc-list a {
  display: block;
  text-decoration: none;
}

.toc-list a:hover {
  color: var(--ink);
}

.book {
  min-width: 0;
}

.book-title-page {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100vh - 3.25rem);
  max-width: var(--measure);
  margin: 0 auto;
  padding: 6rem 1.25rem;
  text-align: center;
}

.series-name,
.volume-number {
  margin: 0;
  color: var(--faint);
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.volume-number {
  margin-top: 1.4rem;
}

.book-title-page h1,
.index-header h1 {
  max-width: var(--reader-title-measure);
  margin: 2rem auto 1rem;
  font-size: var(--reader-title-size);
  font-weight: var(--reader-title-weight);
  letter-spacing: var(--reader-title-letter-spacing);
  line-height: var(--reader-title-line-height);
}

.book-subtitle,
.index-dek {
  max-width: var(--reader-subtitle-measure);
  margin: 0 auto;
  color: var(--muted);
  font-size: var(--reader-subtitle-size);
  font-style: italic;
  font-weight: var(--reader-subtitle-weight);
  line-height: var(--reader-subtitle-line-height);
}

.title-rule {
  width: 3.2rem;
  height: 1px;
  margin: 2.5rem auto;
  background: var(--rule);
}

.book-author {
  margin: 0;
  font-size: 1.1rem;
}

.book-meta {
  margin: 0.65rem 0 0;
  color: var(--faint);
  font-size: 0.85rem;
  line-height: 1.6;
}

.book-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.8rem;
  margin-top: 2rem;
}

.download-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.58rem 0.95rem;
  border: 1px solid transparent;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  transition: background 150ms ease, border-color 150ms ease, transform 50ms ease;
}

.download-button:active {
  transform: translateY(0.5px);
}

.download-button svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.download-button-primary {
  background: var(--ink);
  color: var(--paper);
}

.download-button-primary:hover {
  background: color-mix(in srgb, var(--ink) 86%, var(--paper));
}

.download-button-secondary {
  border-color: var(--rule);
  background: var(--wash);
  color: var(--ink);
  box-shadow: 0 1px 2px color-mix(in srgb, var(--ink) 10%, transparent);
}

.download-button-secondary:hover {
  border-color: var(--faint);
}

.mobile-toc {
  display: none;
}

.book-text {
  max-width: var(--body-measure);
  margin: 0 auto;
  padding: 3rem 1.25rem 8rem;
}

.book-text p {
  margin: 0 0 1.15em;
}

.book-text h2,
.book-text h3,
.book-text h4,
.book-text h5,
.book-text h6 {
  position: relative;
  font-weight: var(--reader-section-title-weight);
  line-height: var(--reader-section-title-line-height);
  text-wrap: balance;
}

.book-text h2 strong,
.book-text h3 strong,
.book-text h4 strong,
.book-text h5 strong,
.book-text h6 strong {
  font-weight: inherit;
}

.book-text h2 {
  margin: 7rem 0 2.4rem;
  padding-top: 2.5rem;
  font-size: clamp(2.15rem, 5vw, 3.45rem);
  text-align: center;
}

.book-text h2::after {
  content: "";
  display: block;
  width: 2.6rem;
  height: 1px;
  margin: 1.8rem auto 0;
  background: var(--rule);
}

.book-text h3 {
  margin: 4rem 0 1.5rem;
  font-size: var(--reader-section-title-size);
  text-align: center;
}

.book-text h4 {
  margin: 3rem 0 1rem;
  font-size: var(--reader-subsection-title-size);
}

.book-text h5 {
  margin: 2.4rem 0 0.8rem;
  font-size: 1.3rem;
}

.book-text h6 {
  margin: 2rem 0 0.7rem;
  font-size: 1.12rem;
  font-style: italic;
  font-weight: 500;
}

.heading-anchor {
  position: absolute;
  left: -1.4em;
  opacity: 0;
  color: var(--faint);
  font-size: 0.55em;
  text-decoration: none;
}

h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor,
.heading-anchor:focus {
  opacity: 1;
}

.book-text blockquote {
  max-width: 34rem;
  margin: 2.8rem auto;
  padding: 0;
  border: 0;
  color: var(--muted);
  font-size: var(--reader-quote-size);
  font-style: italic;
  font-weight: var(--reader-quote-weight);
  text-align: center;
}

.book-text blockquote p:last-child {
  margin-bottom: 0;
}

.condition {
  margin: 2rem 0;
  padding: 0.2rem 0 0.2rem 1rem;
  border-left: 2px solid var(--rule);
  font-weight: 500;
}

.condition p {
  margin: 0;
}

.book-text ul,
.book-text ol {
  margin: 0 0 1.4rem;
  padding-left: 1.6rem;
}

.book-text li + li {
  margin-top: 0.35rem;
}

.book-text hr {
  width: 3.2rem;
  height: 1px;
  margin: 3rem auto;
  border: 0;
  background: var(--rule);
}

.math-inline {
  white-space: nowrap;
}

.math-display {
  max-width: 100%;
  margin: 2.2rem 0;
  padding: 0.7rem 0;
  overflow-x: auto;
  text-align: center;
}

.table-scroll {
  width: 100%;
  max-width: 100%;
  margin: 3.2rem 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: color-mix(in srgb, var(--paper) 96%, var(--wash));
  box-shadow: 0 10px 35px color-mix(in srgb, var(--ink) 7%, transparent);
  scrollbar-width: thin;
  scrollbar-color: var(--faint) transparent;
}

table {
  width: 100%;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
  line-height: 1.5;
}

th,
td {
  min-width: 0;
  padding: 1rem 1.15rem;
  border-right: 1px solid color-mix(in srgb, var(--rule) 55%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--rule) 75%, transparent);
  text-align: left;
  vertical-align: top;
  overflow-wrap: break-word;
}

th:first-child,
td:first-child,
th:last-child,
td:last-child {
  width: 1%;
  white-space: nowrap;
}

th:last-child,
td:last-child {
  border-right: 0;
}

tbody tr:last-child td {
  border-bottom: 0;
}

th {
  padding-top: 0.9rem;
  padding-bottom: 0.9rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 0.88rem;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.055em;
  line-height: 1.35;
  text-transform: uppercase;
}

tbody tr:nth-child(even) {
  background: var(--wash);
}

tbody tr {
  transition: background 120ms ease;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--wash) 72%, var(--paper));
}

tbody td[scope="row"] {
  font-weight: 500;
}

code,
pre {
  font-size: 0.82em;
}

pre {
  padding: 1rem;
  overflow: auto;
  background: var(--wash);
}

.volume-footer {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 4rem 1.25rem 7rem;
  border-top: 1px solid var(--rule);
}

.footer-volume-nav {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 5vw, 4rem);
  margin: 0 0 2.5rem;
}

.footer-volume-link {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
  min-height: 6rem;
  padding: 1.25rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
}

.footer-volume-link:hover {
  border-color: var(--ink);
}

.footer-volume-copy {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.footer-volume-copy small {
  color: var(--faint);
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.footer-volume-copy strong {
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.15;
}

.footer-volume-arrow {
  font-family: var(--sans);
  font-size: 1.8rem;
  line-height: 1;
}

.footer-volume-next {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-column: 2;
  text-align: right;
}

.footer-volume-previous {
  grid-column: 1;
}

.back-to-series {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
}

.series-index {
  min-height: 100vh;
  padding: clamp(2rem, 6vw, 6rem) clamp(1.25rem, 5vw, 5rem);
}

.index-header {
  max-width: 70rem;
  margin: 0 auto;
  padding: clamp(4rem, 10vw, 9rem) 0;
  text-align: center;
}

.index-header h1 {
  max-width: none;
}

.reader-page .book-title-page h1 {
  max-width: var(--reader-title-measure);
  font-size: var(--reader-title-size);
}

.series-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 70rem;
  margin: 0 auto;
  border-top: 1px solid var(--rule);
  border-left: 1px solid var(--rule);
}

.series-card {
  min-height: 25rem;
  padding: clamp(2rem, 5vw, 4rem);
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.series-card h2 {
  max-width: 13ch;
  margin: 1.2rem 0 0.7rem;
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 400;
  line-height: 1;
}

.series-card h2 a {
  text-decoration: none;
}

.card-subtitle {
  color: var(--muted);
  font-style: italic;
}

.series-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  color: var(--faint);
  font-size: 0.82rem;
}

.index-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  max-width: 70rem;
  margin: 4rem auto 0;
  color: var(--faint);
  font-size: 0.82rem;
}

.library-volumes,
.volume-work-list {
  width: min(100%, 76rem);
  margin: 0 auto;
}

.library-volume {
  display: grid;
  grid-template-columns: minmax(13rem, 0.7fr) minmax(0, 1.3fr);
  column-gap: clamp(2rem, 6vw, 7rem);
  padding: clamp(3rem, 7vw, 6rem) 0;
  border-top: 1px solid var(--rule);
}

.library-volume > .volume-number,
.library-volume > h2,
.library-volume > p,
.library-volume > .volume-overview-link {
  grid-column: 1;
}

.library-volume h2 {
  margin: 0.8rem 0 1.2rem;
  font-size: clamp(2rem, 4vw, 3.5rem);
  font-weight: 400;
  line-height: 1;
}

.library-volume > p:not(.volume-number) {
  margin: 0;
  color: var(--muted);
}

.library-volume ol {
  grid-column: 2;
  grid-row: 1 / span 5;
  margin: 0;
  padding: 0;
  list-style: none;
}

.library-volume li {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr);
  gap: 1.2rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--rule) 70%, transparent);
}

.library-volume li:first-child {
  padding-top: 0;
}

.library-volume li span,
.work-sequence {
  color: var(--faint);
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.library-volume li a {
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
}

.volume-overview-link,
.collection-back,
.work-read-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1.5rem;
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
}

.collection-back {
  margin: 0 0 3rem;
}

.volume-work-list {
  border-top: 1px solid var(--rule);
}

.work-list-item {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr) auto;
  gap: 1.5rem;
  align-items: start;
  padding: 2.2rem 0;
  border-bottom: 1px solid var(--rule);
}

.work-list-item h2 {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2.3rem);
  font-weight: 400;
  line-height: 1.05;
}

.work-list-item h2 a {
  text-decoration: none;
}

.work-list-item .card-subtitle {
  grid-column: 2;
  margin: -0.7rem 0 0;
}

.work-list-item .work-read-link {
  grid-column: 3;
  grid-row: 1 / span 2;
  margin: 0;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .running-header {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .running-title {
    display: none;
  }

  .back-label-full {
    display: none;
  }

  .back-label-short {
    display: inline;
  }

  .toc-button {
    display: block;
  }

  .reader-grid {
    display: block;
    width: 100%;
  }

  .toc-rail {
    display: none;
  }

  .mobile-toc {
    display: block;
    max-width: var(--measure);
    margin: 0 auto 2rem;
    padding: 0 1.25rem 1rem;
    border-bottom: 1px solid var(--rule);
    font-size: 0.9rem;
  }

  .mobile-toc summary {
    padding: 1rem 0;
    cursor: pointer;
  }

  .mobile-toc .toc-list {
    max-height: 65vh;
    padding: 0.5rem 0 1.5rem;
    overflow: auto;
  }

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

  .library-volume {
    display: block;
  }

  .library-volume ol {
    margin-top: 2.5rem;
  }

  .work-list-item {
    grid-template-columns: 5.5rem minmax(0, 1fr);
  }

  .work-list-item .work-read-link {
    grid-column: 2;
    grid-row: auto;
  }
}

@media (max-width: 700px) {
  .table-scroll {
    width: calc(100vw - 1rem);
    margin: 2.5rem 50%;
    border-radius: 10px;
    transform: translateX(-50%);
  }

  table {
    font-size: 1rem;
  }

  table:has(th:nth-child(3)) {
    min-width: 44rem;
  }

  th,
  td {
    padding: 0.9rem 1rem;
  }

  table:not(:has(th:nth-child(3))) {
    min-width: 0;
  }

  table:not(:has(th:nth-child(3))) thead,
  table:not(:has(th:nth-child(3))) tbody {
    display: block;
  }

  table:not(:has(th:nth-child(3))) tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  table:not(:has(th:nth-child(3))) th,
  table:not(:has(th:nth-child(3))) td {
    min-width: 0;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 1.08rem;
  }

  .running-header {
    gap: 0.4rem;
    padding-right: 0.7rem;
    padding-left: 0.7rem;
  }

  .library-back,
  .volume-step,
  .toc-button,
  .document-search-toggle,
  .theme-toggle {
    padding-right: 0.42rem;
    padding-left: 0.42rem;
  }

  .header-navigation {
    gap: 0.05rem;
  }

  .volume-step {
    min-width: 2rem;
    justify-content: center;
  }

  .volume-step span:not([aria-hidden="true"]) {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .document-search-toggle span,
  .running-header .theme-toggle span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .document-search-panel {
    top: 3.8rem;
    right: 0.7rem;
    left: 0.7rem;
    width: auto;
  }

  .document-search-form {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .document-search-field {
    grid-column: 1 / -1;
  }

  .document-search-field kbd {
    display: none;
  }

  .document-search-status {
    text-align: left;
  }

  .book-title-page {
    min-height: 90vh;
    padding-top: 4rem;
  }

  .book-text h2 {
    margin-top: 5rem;
  }

  .heading-anchor {
    position: static;
    margin-left: 0.45rem;
  }

  .footer-volume-nav {
    gap: 1rem;
  }

  .footer-volume-link {
    gap: 0.55rem;
    min-height: 5rem;
  }

  .footer-volume-copy strong {
    font-size: 0.9rem;
  }

  .footer-volume-copy small {
    font-size: 0.66rem;
    letter-spacing: 0.06em;
    white-space: nowrap;
  }

  .footer-volume-arrow {
    font-size: 1.35rem;
  }

  .series-index {
    padding-inline: 1rem;
  }

  .index-footer {
    flex-direction: column;
  }

  .library-volume li,
  .work-list-item {
    display: block;
  }

  .library-volume li span,
  .work-sequence {
    display: block;
    margin-bottom: 0.45rem;
  }

  .work-list-item .card-subtitle,
  .work-list-item .work-read-link {
    margin-top: 0.8rem;
  }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --paper: #14140f;
    --ink: #e9e5d8;
    --muted: #b3ad9c;
    --faint: #8e8879;
    --rule: #3a382f;
    --accent: #e9e5d8;
    --wash: #1d1c16;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media print {
  @page {
    size: A4;
    margin: 25mm;
  }

  :root,
  :root[data-theme="light"],
  :root[data-theme="dark"] {
    color-scheme: light;
    --paper: #fff;
    --ink: #000;
    --muted: #333;
    --faint: #555;
    --rule: #bbb;
    --wash: #f6f6f6;
  }

  body {
    font-size: 10.5pt;
    line-height: 1.45;
  }

  .running-header,
  .document-search-panel,
  .theme-toggle,
  .toc-rail,
  .mobile-toc,
  .book-actions,
  .volume-footer,
  .heading-anchor {
    display: none !important;
  }

  .reader-grid {
    display: block;
    width: auto;
  }

  .book-title-page {
    min-height: 245mm;
    padding: 30mm 0;
    break-after: page;
  }

  .book-text {
    max-width: none;
    padding: 0;
  }

  .book-text h2 {
    break-before: page;
    break-after: avoid;
    margin-top: 0;
  }

  .book-text h3,
  .book-text h4,
  .book-text h5,
  .book-text h6,
  .condition,
  table,
  figure {
    break-inside: avoid;
  }

  a {
    text-decoration: none;
  }
}
