.element-detail-page-header,
.element-detail-magazine {
  --mag-paper: #fbf8f4;
  --mag-ink: #2d2924;
  --mag-muted: rgb(45 41 36 / 62%);
  --mag-rule: rgb(45 41 36 / 18%);
}

#main-panel:has(.element-detail-magazine) {
  position: relative;
  min-height: 100vh;
  background: var(--mag-paper, #fbf8f4);
}

body:has(.element-detail-magazine) {
  background: #fbf8f4;
}

html:has(.element-detail-magazine) {
  background: #fbf8f4;
}

body:has(.element-detail-magazine) #primary-sidebar {
  background: #fbf8f4;
  border-color: var(--mag-rule, rgb(45 41 36 / 18%));
}

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

body:has(.element-detail-magazine) .sticky.top-0.z-40 {
  border-bottom: 1px solid var(--mag-rule, rgb(45 41 36 / 18%));
  background: #fbf8f4;
  box-shadow: none;
}

body:has(.element-detail-magazine) #sidebar .bg-white {
  background: #fbf8f4;
}

body:has(.element-detail-magazine) #primary-sidebar a,
body:has(.element-detail-magazine) #primary-sidebar button,
body:has(.element-detail-magazine) #sidebar a,
body:has(.element-detail-magazine) #sidebar button {
  color: var(--mag-ink, #2d2924);
}

.element-detail-magazine .generated-image-actions svg {
  width: 1.875rem;
  height: 1.875rem;
}

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

body:has(.element-detail-magazine) #primary-sidebar el-menu,
body:has(.element-detail-magazine) #sidebar el-menu,
body:has(.element-detail-magazine) .generated-image el-menu {
  background: #fbf8f4;
  color: var(--mag-ink, #2d2924);
}

.element-detail-page-header {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  padding: .5rem 0 .25rem;
  margin-bottom: 0 !important;
}

.element-detail-page-header-copy {
  max-width: min(100%, 56%);
  text-align: left;
}

.element-detail-page-title {
  margin-top: 0;
  color: var(--mag-ink);
  font-family: "Atkinson Hyperlegible", sans-serif;
  font-size: clamp(5.12rem, 7.68vw, 8rem);
  font-weight: 500;
  letter-spacing: -.035em;
  line-height: .92;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
  text-wrap: balance;
}

.element-detail-page-title,
.editorial-content-card h3,
.chapter-detail-page-title,
.text-overview-title {
  min-width: 0;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

.element-detail-magazine {
  padding: 0 clamp(.75rem, 1.5vw, 1.5rem) 3rem;
  background: var(--mag-paper);
  color: var(--mag-ink);
  font-family: "Atkinson Hyperlegible", sans-serif;
}

.element-detail-hero-card {
  padding: 0;
}

.element-detail-editorial-grid {
  display: flex;
  flex-direction: column;
}

.editorial-plan-quote-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .5rem;
}

.editorial-plan-quote-card {
  border: 1px solid transparent;
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.editorial-plan-quote-label {
  display: block;
  height: 100%;
  cursor: pointer;
}

.editorial-plan-quote-card--selected {
  border-color: rgb(79 70 229);
  background: rgb(238 242 255);
  box-shadow: 0 0 0 1px rgb(79 70 229 / .18);
}

.editorial-plan-quote-card--limit {
  border-color: rgb(220 38 38);
  background: rgb(254 242 242);
  animation: editorial-quote-limit-flash .85s ease-in-out;
}

.editorial-plan-quote-limit-message {
  color: rgb(185 28 28);
  font-size: .75rem;
  font-weight: 600;
}

@keyframes editorial-quote-limit-flash {
  0%, 100% { box-shadow: 0 0 0 0 rgb(220 38 38 / 0); }
  50% { box-shadow: 0 0 0 5px rgb(220 38 38 / .28); }
}

@media (max-width: 640px) {
  .editorial-plan-quote-grid { grid-template-columns: 1fr; }
}

.element-detail-editorial-copy {
  width: 100%;
  min-width: 0;
}

.element-detail-editorial-copy::after {
  display: block;
  clear: both;
  content: "";
}

.element-detail-summary {
  padding: 1rem 0 1.15rem;
}

.element-detail-summary-text {
  max-width: 44rem;
  margin-top: .8rem;
  color: var(--mag-ink);
  font-size: clamp(2.08rem, 2.72vw, 2.8rem);
  line-height: 1.28;
}

.element-detail-secondary {
  color: var(--mag-muted);
  font-family: "Atkinson Hyperlegible", sans-serif;
  font-size: .75rem;
  letter-spacing: .04em;
  line-height: 1.5;
}

.element-detail-image-frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: auto;
  max-height: 34rem;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: .5rem;
  background: transparent;
}

.element-detail-visual {
  position: relative;
  z-index: 1;
  width: 100%;
  margin: 0;
  order: 2;
}

.element-detail-visual .generated-image,
.element-detail-visual .watercolour-frame,
.element-detail-visual .element-detail-image {
  max-width: 100%;
  max-height: 100%;
}

.element-detail-image {
  display: block;
  height: 100%;
  width: 100%;
  object-fit: contain;
  object-position: center center;
  border-radius: .5rem;
  background: transparent;
  -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;
}

.element-detail-image-frame.generated-image {
  overflow: visible;
}

.element-detail-image-frame.generated-image .element-detail-image {
  opacity: 1;
  mix-blend-mode: normal;
  border-radius: 0;
}

.element-detail-image-frame.generated-image .watercolour-frame {
  overflow: visible;
}

.element-detail-image-frame--empty {
  min-height: 18rem;
  border-radius: .25rem;
  background: rgb(255 255 255 / 36%);
}

.element-detail-image-frame--empty .generated-image-placeholder {
  border: 0;
}

.element-detail-quotes > .flex {
  margin-top: 2rem;
  padding-top: 0;
  align-items: baseline;
}

.editorial-content-section {
  width: fit-content;
  max-width: 100%;
  padding-top: 1rem;
}

.editorial-content-image {
  width: 100%;
}

.editorial-content-image-card,
.editorial-content-image-card .editorial-content-image-frame,
.editorial-content-image-card .editorial-content-image-frame .watercolour-frame {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  overflow: visible;
  border-radius: 0;
  background: transparent;
}

.editorial-content-image-card .editorial-content-image-frame .element-detail-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
  object-position: center center;
  border-radius: 0;
  opacity: 1;
  mix-blend-mode: normal;
}

.editorial-content-image--primary {
  margin-left: auto;
}

.editorial-content-image--symbolic {
  margin-right: auto;
}

.editorial-content-analysis b,
.editorial-content-analysis strong {
  font-size: 1.15em;
}

.group\/editorial-pull-quote strong {
  font-size: 1.38em;
}

/* Pull quotes are display type, but still need to read as one compact passage. */
.editorial-pull-quote-text {
  line-height: 1.25;
}

/* The selected source fragment is the visual hinge of a passage. */
.editorial-source-passage strong {
  font-size: 2em;
  font-weight: 700;
}

.editorial-content-title-options-button {
  border-radius: 9999px;
  color: var(--mag-ink);
  background: radial-gradient(circle, rgb(209 213 219 / 0.78) 0%, rgb(209 213 219 / 0.52) 58%, rgb(209 213 219 / 0) 100%);
  transition: color .15s ease, background .15s ease;
}

.editorial-content-title-options-button:hover {
  color: #111827;
  background: radial-gradient(circle, rgb(209 213 219 / 0.95) 0%, rgb(209 213 219 / 0.68) 58%, rgb(209 213 219 / 0) 100%);
}

.editorial-content-title-options-button:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

@media (min-width: 768px) {
  .editorial-content-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .editorial-content-media {
    grid-column: 2;
    grid-row: 1;
    order: 1;
  }

  .editorial-content-copy {
    grid-column: 1;
    grid-row: 1;
    order: 2;
  }
}

@media (max-width: 767px) {
  .editorial-content-media {
    order: 1;
  }

  .editorial-content-copy {
    order: 2;
  }
}

.element-detail-quotes #quote-list {
  margin-top: 1rem;
}

.element-detail-magazine .quote-card {
  border-radius: 0;
  border-top: 0;
  border-bottom: 0;
  background: transparent;
  box-shadow: none;
}

.element-detail-summary {
  border-top: 0;
}

@media (min-width: 768px) {
  .element-detail-editorial-grid {
    display: block;
  }

  .element-detail-visual {
    float: none;
    width: 100%;
    margin: .5rem 0 1.5rem;
  }

  .element-detail-summary-text {
    max-width: none;
  }

}

/* The desktop shell normally enlarges analysis pages. Keep these editorial
   layouts in viewport coordinates so the image cannot cross the midpoint. */
@media (min-width: 1024px) {
  main:has(.element-detail-magazine) {
    zoom: 1;
  }
}

/* Give the editorial prose a readable 50% size increase while keeping the
   surrounding navigation and controls at their established scale. */
.element-detail-magazine .editorial-content-card .text-base {
  font-size: 1.5rem;
  line-height: 1.75;
}

/* Source passages contain ordinary wrapped prose, not separately spaced
   paragraphs. Keep their enlarged type while restoring a compact reading
   rhythm. */
.element-detail-magazine .editorial-source-passage {
  line-height: 1.25;
}

@media (min-width: 768px) {
  .element-detail-magazine .editorial-content-card .editorial-content-title {
    font-size: 3.5rem;
  }
}

@media (max-width: 767px) {
  #main-panel:has(.element-detail-magazine) {
    padding-top: 1.5rem;
  }

  .element-detail-page-header {
    margin-bottom: 0;
  }

  .element-detail-magazine { padding-top: 0; }

  .element-detail-editorial-copy {
    order: 1;
    width: 100%;
  }

  .element-detail-visual {
    float: none;
    width: 100%;
    margin: 0 0 1rem;
  }

}
