.chapter-detail-paper {
  --chapter-paper: #fbf8f4;
  --chapter-ink: #2d2924;
  --chapter-muted: rgb(45 41 36 / 62%);
  --chapter-rule: transparent;
  background: var(--chapter-paper);
  color: var(--chapter-ink);
  font-family: "Atkinson Hyperlegible", sans-serif;
}

#main-panel:has(.chapter-detail-paper),
body:has(.chapter-detail-paper),
html:has(.chapter-detail-paper) {
  background: #fbf8f4;
}

#main-panel:has(.chapter-detail-paper) {
  min-height: 100vh;
}

body:has(.chapter-detail-paper) #primary-sidebar {
  background: #fbf8f4;
  border: 0;
}

body:has(.chapter-detail-paper) #primary-sidebar .bg-gray-100,
body:has(.chapter-detail-paper) #primary-sidebar .bg-indigo-100 {
  background: rgb(45 41 36 / 10%);
  color: var(--chapter-ink);
}

body:has(.chapter-detail-paper) #primary-sidebar a,
body:has(.chapter-detail-paper) #primary-sidebar button {
  color: var(--chapter-ink);
}

body:has(.chapter-detail-paper) #primary-sidebar .narrative-element-nav:hover {
  background: rgb(45 41 36 / 8%);
}

.chapter-detail-page-header {
  margin-bottom: .75rem !important;
  padding: .5rem 0 1rem;
  border: 0;
}

.chapter-detail-top-navigation {
  text-align: left;
}

.chapter-detail-page-header {
  text-align: right;
}

.chapter-detail-navigation {
  justify-content: flex-end;
}

.chapter-detail-page-kicker,
.chapter-detail-section-title {
  color: var(--chapter-muted);
  font-family: "Atkinson Hyperlegible", sans-serif;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .2em;
  line-height: 1.4;
  text-transform: uppercase;
}

.chapter-detail-page-title {
  margin-top: .35rem !important;
  color: var(--chapter-ink);
  font-family: "Atkinson Hyperlegible", sans-serif;
  font-size: clamp(2.2rem, 4vw, 4.25rem);
  font-weight: 500;
  letter-spacing: -.035em;
  line-height: .95;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
  text-wrap: balance;
}

.chapter-detail-card {
  min-height: 0 !important;
  padding: 1rem 0 1.25rem !important;
  border: 0 !important;
  border-top: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.chapter-detail-overview-left {
  min-width: 0;
}

.chapter-detail-overview-left .chapter-detail-card + .chapter-detail-card {
  margin-top: 2.5rem;
}

.chapter-detail-prose,
.chapter-detail-events {
  color: var(--chapter-ink);
  font-size: 1.08rem;
  line-height: 1.58;
}

.chapter-detail-events {
  position: relative;
  margin-top: .85rem !important;
  padding-left: 1.35rem;
}

.chapter-detail-events::before {
  position: absolute;
  top: .35rem;
  bottom: .35rem;
  left: .25rem;
  width: 1px;
  background: rgb(45 41 36 / 24%);
  content: "";
}

.chapter-detail-event {
  position: relative;
  display: block;
  padding-left: .85rem;
}

.chapter-detail-event + .chapter-detail-event {
  margin-top: 1.1rem;
}

.chapter-detail-event-marker {
  position: absolute;
  top: .45rem;
  left: -.05rem;
  width: .55rem;
  height: .55rem;
  border: 1px solid var(--chapter-ink);
  border-radius: 999px;
  background: var(--chapter-paper);
}

.chapter-detail-image-card {
  padding-top: 1rem !important;
}

.chapter-detail-image-card .generated-image {
  margin-top: .75rem;
  overflow: visible;
  height: min(32rem, 38vw);
}

.chapter-detail-image-card .generated-image img {
  width: 100% !important;
  height: min(32rem, 38vw) !important;
  max-height: 32rem;
  border-radius: 0 !important;
  background: #fbf8f4 !important;
  object-fit: contain !important;
  opacity: .94;
  mix-blend-mode: normal;
  -webkit-mask-image: url("/static/images/soft-edge-mask.png");
  mask-image: url("/static/images/soft-edge-mask.png");
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

.chapter-detail-image-empty {
  height: 18rem !important;
  border: 0 !important;
  border-radius: .25rem !important;
  background: rgb(255 255 255 / 36%) !important;
}

@media (max-width: 1023px) {
  .chapter-detail-image-card {
    order: -1;
  }
}

.chapter-comments .mobile-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.chapter-comments-refresh { display: inline-flex; width: 2rem; height: 2rem; align-items: center; justify-content: center; border: 0; border-radius: 999px; background: transparent; color: #78716c; cursor: pointer; }
.chapter-comments-refresh:hover { background: #f5f5f4; color: #292524; }
.chapter-comments-refresh svg { width: 1rem; height: 1rem; }
.chapter-comments-button { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; }
.chapter-comments-button svg { width: 1.1rem; height: 1.1rem; flex: 0 0 auto; }
.chapter-comments-disclosure { margin-top: 1.25rem; border-top: 1px solid #e7e0d4; }
.chapter-comments-disclosure > summary { padding: .8rem 0; color: #57534e; cursor: pointer; font-size: .875rem; font-weight: 700; list-style: none; }
.chapter-comments-disclosure > summary::-webkit-details-marker { display: none; }
.chapter-comments-disclosure > summary::marker { content: ""; }
.chapter-comments-disclosure[open] > summary { border-bottom: 1px solid #e7e0d4; }
.reader-comment-threads { display: grid; gap: 1rem; margin-top: 1.25rem; }
.reader-comment { display: grid; grid-template-columns: 2.4rem 1fr; gap: .75rem; border-radius: 1rem; background: #fff; padding: 1rem; }
.reader-comment-reply { margin-left: 2.5rem; border-left: 2px solid #e7e0d4; }
.reader-comment-avatar { display: grid; width: 2.4rem; height: 2.4rem; place-items: center; border-radius: 50%; background: #eee5d8; object-fit: cover; font-weight: 700; }
.reader-comment strong, .reader-comment small { display: block; }
.reader-comment small { color: #78716c; font-size: .72rem; }
.reader-comment p { margin: .3rem 0 0; }
.reader-comment-loading { display: grid; grid-template-columns: 2.5rem 1fr; gap: .75rem; margin-top: 1rem; border-radius: 1rem; background: #fff; padding: 1rem; }
.reader-typing-avatar { position: relative; z-index: 0; display: grid; width: 2.5rem; height: 2.5rem; place-items: center; border-radius: 50%; background: #fff; color: #7e22ce; letter-spacing: .15em; }
.reader-typing-avatar::before { content: ""; position: absolute; inset: -.2rem; z-index: -1; border-radius: 50%; background: conic-gradient(#60a5fa, #9333ea, #ec4899, #60a5fa); animation: reader-border-spin 1.1s linear infinite; }
.mobile-refresh-button, .mobile-comment-reveal { margin-top: .75rem; border: 1px solid #d6d3d1; border-radius: 999px; background: #fff; padding: .55rem 1rem; font-weight: 700; }
.reader-comment-error { color: #b91c1c; }

@media (max-width: 767px) {
  .chapter-detail-image-card .generated-image {
    height: auto;
    aspect-ratio: 1 / 1;
    background: #fbf8f4;
  }

  .chapter-detail-image-card .generated-image img {
    height: 100% !important;
  }
}

.chapter-detail-paper .chapter-element-card {
  border-color: var(--chapter-rule);
  border-radius: .35rem;
  background: rgb(255 255 255 / 30%);
  box-shadow: none;
}

.chapter-detail-paper .chapter-element-card:hover {
  border-color: rgb(45 41 36 / 30%);
  background: rgb(255 255 255 / 54%);
}

.chapter-detail-paper .chapter-element-card img,
.chapter-detail-paper .chapter-element-card span.flex {
  border-radius: .25rem;
  background: rgb(255 255 255 / 28%);
  box-shadow: none;
}

.chapter-detail-secondary-section {
  border-top: 0;
  padding-top: 1rem;
}

.chapter-detail-secondary-section > div:first-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.chapter-detail-empty {
  border-color: var(--chapter-rule) !important;
  border-radius: .25rem !important;
  background: transparent;
  color: var(--chapter-muted);
}

.chapter-detail-reader {
  border: 0 !important;
  border-top: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.chapter-detail-reader summary {
  padding: 1rem 0 !important;
}

.chapter-detail-reader summary span:first-child {
  color: var(--chapter-muted);
  font-family: "Atkinson Hyperlegible", sans-serif;
  font-size: .68rem;
  letter-spacing: .2em;
  text-transform: uppercase;
}

.chapter-detail-reader summary span:last-child {
  color: var(--chapter-muted);
}

.chapter-detail-reader > div {
  border-color: var(--chapter-rule) !important;
  padding-right: 0 !important;
  padding-left: 0 !important;
}

.chapter-detail-reader [data-annotated-chapter-text] {
  color: var(--chapter-ink);
  font-family: "Atkinson Hyperlegible", sans-serif;
}

@media (max-width: 1023px) {
  .chapter-detail-image-card .generated-image {
    height: min(28rem, 70vw);
  }

  .chapter-detail-image-card .generated-image img {
    height: min(28rem, 70vw) !important;
  }
}
