/* Native Discuz post reading enhancements — deliberately scoped to post content. */
.xbp-reading,
.xb-post .xbp-reading {
  --xbp-ink: #203454;
  --xbp-muted: #687b98;
  --xbp-blue: #1d5bce;
  --xbp-blue-deep: #1648aa;
  --xbp-line: #dce7f7;
  --xbp-wash: #f2f7ff;
  color: var(--xbp-ink);
  line-height: 1.9;
  overflow-wrap: anywhere;
}

.xbp-reading .xbp-paragraph {
  margin: 0 0 1.18em;
  line-height: 1.95;
  text-wrap: pretty;
}

.xbp-reading .xbp-paragraph:last-child {
  margin-bottom: 0;
}

.xbp-reading .xbp-paragraph strong,
.xbp-reading .xbp-paragraph b {
  color: #173d77;
  font-weight: 650;
}

.xbp-reading .xbp-source-intro {
  margin: 1.65em 0 .55em;
  padding: 0 0 .45em;
  border-bottom: 1px solid var(--xbp-line);
  line-height: 1.5;
}

.xbp-reading .xbp-source-heading {
  display: inline-block;
  color: #183d75;
  font-size: inherit;
  letter-spacing: .025em;
}

.xbp-reading figure.xbp-figure {
  margin: 1.35em 0 .45em;
  text-align: center;
}

.xbp-reading figure.xbp-figure > img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: min(68vh, 680px);
  height: auto;
  margin: 0 auto;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 5px 22px rgba(32, 66, 120, .11);
}

.xbp-reading figure.xbp-figure figcaption {
  max-width: 58em;
  margin: .6em auto 0;
  color: var(--xbp-muted);
  font-size: .78em;
  line-height: 1.65;
  text-align: left;
}

.xbp-reading .xbp-image-error {
  margin: .65em 0;
  padding: .6em .85em;
  border: 1px solid #d8e5f7;
  border-radius: 8px;
  background: #f5f8fd;
  color: var(--xbp-muted);
  font-size: .8em;
  line-height: 1.55;
  text-align: center;
}

/* Inline links stay part of the sentence; source links read as compact action buttons. */
.xbp-reading a.xbp-link {
  display: inline-flex;
  align-items: center;
  gap: .5em;
  box-sizing: border-box;
  max-width: 100%;
  margin: .15em .1em;
  padding: .35em .6em;
  border: 1px solid var(--xbp-line);
  border-radius: 9px;
  background: var(--xbp-wash);
  vertical-align: middle;
  color: var(--xbp-blue);
  text-decoration: none;
  text-decoration-color: #9bb8eb;
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
  overflow-wrap: anywhere;
}

.xbp-reading a.xbp-link:hover {
  color: var(--xbp-blue-deep);
  text-decoration-color: currentColor;
}

.xbp-reading a.xbp-link:focus-visible {
  outline: 3px solid #79a7f2;
  outline-offset: 3px;
  border-radius: 4px;
}

.xbp-reading .xbp-paragraph:has(> a.xbp-link:only-child),
.xbp-reading .xbp-paragraph:has(> a.xbp-link + br),
.xbp-reading .xbp-paragraph:has(> br + a.xbp-link) {
  margin: .7em 0;
}

.xbp-reading a.xbp-link .xbp-link-icon {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 1.55em;
  height: 1.55em;
  flex: 0 0 1.55em;
  overflow: hidden;
  border: 1px solid #dce7f7;
  border-radius: 7px;
  background: #f2f7ff;
  color: #5480c6;
}

.xbp-reading .xbp-link-icon > svg,
.xbp-reading .xbp-link-icon > img {
  display: block;
  width: 1em;
  height: 1em;
  max-width: 1em;
  max-height: 1em;
  border-radius: 2px;
}

.xbp-reading .xbp-link-icon > img {
  display: block;
  position: absolute;
  opacity: 0;
  object-fit: contain;
}

.xbp-reading .xbp-link-icon.xbp-icon-loaded > img {
  display: block;
  opacity: 1;
}

.xbp-reading .xbp-link-icon.xbp-icon-loaded > svg {
  display: none;
}

/* Native reading-services.css deliberately inherits all post font sizes.
   Keep source metadata subordinate without disabling the reader's --rs scale. */
.xbp-reading .xbp-link-domain { font-size: .72em !important; }
.xbp-reading figure.xbp-figure figcaption { font-size: .78em !important; }
.xbp-reading .xbp-image-error { font-size: .8em !important; }

.xbp-reading a.xbp-link .xbp-link-text {
  display: inline-flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  gap: .06em;
  line-height: 1.4;
  text-decoration: none;
}

.xbp-reading a.xbp-link .xbp-link-title {
  display: block;
  min-width: 0;
  font-size: inherit;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.xbp-reading a.xbp-link .xbp-link-domain {
  display: block;
  min-width: 0;
  color: var(--xbp-muted);
  font-size: .72em;
  font-weight: 400;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.xbp-reading a.xbp-link .xbp-link-arrow {
  display: inline-grid;
  place-items: center;
  flex: 0 0 1em;
  width: 1em;
  height: 1em;
  color: #7891b8;
}

.xbp-reading .xbp-link-arrow > svg {
  display: block;
  width: 1em;
  height: 1em;
}

/* A paragraph dedicated to a link becomes a lightly framed source button. */
.xbp-reading .xbp-paragraph:has(> a.xbp-link:only-child) > a.xbp-link,
.xbp-reading .xbp-paragraph:has(> a.xbp-link + br) > a.xbp-link,
.xbp-reading .xbp-paragraph:has(> br + a.xbp-link) > a.xbp-link {
  display: inline-flex;
  align-items: center;
  gap: .65em;
  max-width: 100%;
  min-width: 0;
  margin: .12em 0;
  padding: .62em .82em;
  border: 1px solid #d7e4f7;
  border-radius: 10px;
  background: linear-gradient(110deg, #f5f9ff, #fff);
  color: #244d87;
  text-decoration: none;
  vertical-align: middle;
  transition: border-color .16s ease, background-color .16s ease, transform .16s ease;
}

.xbp-reading .xbp-paragraph:has(> a.xbp-link:only-child) > a.xbp-link:hover,
.xbp-reading .xbp-paragraph:has(> a.xbp-link + br) > a.xbp-link:hover,
.xbp-reading .xbp-paragraph:has(> br + a.xbp-link) > a.xbp-link:hover {
  border-color: #9bb9e8;
  background: #f0f6ff;
  transform: translateY(-1px);
}

.xbp-reading img[smilieid] {
  display: inline;
  width: auto !important;
  height: auto !important;
  max-width: 1.35em !important;
  max-height: 1.35em !important;
  margin: 0 .08em;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  object-fit: contain;
  vertical-align: -.22em;
}

@media (max-width: 600px) {
  .xbp-reading .xbp-paragraph {
    margin-bottom: 1em;
    line-height: 1.88;
  }

  .xbp-reading figure.xbp-figure > img {
    max-height: 58vh;
    border-radius: 9px;
  }

  .xbp-reading .xbp-paragraph:has(> a.xbp-link:only-child) > a.xbp-link,
  .xbp-reading .xbp-paragraph:has(> a.xbp-link + br) > a.xbp-link,
  .xbp-reading .xbp-paragraph:has(> br + a.xbp-link) > a.xbp-link {
    width: 100%;
    padding: .62em .72em;
  }
}

@media (prefers-reduced-motion: reduce) {
  .xbp-reading a.xbp-link {
    transition: none;
  }
}
