/* ==========================================================================
   Bibelskolan — FM4 Academic Reader Stylesheet
   Strictly uses FM4 CSS Custom Properties (--fm4-*) with Light & Dark Parity.
   Zero hardcoded hex colors, zero hardcoded pixel radii, zero inline styles.
   ========================================================================== */

:root {
  --bs-sidebar-w: 320px;
  --bs-measure: var(--fm4-article-measure, 68ch);
  --bs-ui-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --bs-font-scale: 1;
}

html {
  scroll-behavior: smooth;
}

body.fm4-bibelskolan-reader {
  margin: 0;
  background: var(--fm4-background-color);
  color: var(--fm4-text-color);
  font-family: var(--fm4-body-font);
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}

/* Override generic FM4 page wrapper padding so the 2-column book shell sits flush */
body.fm4-bibelskolan-reader #fm4-page,
body.fm4-bibelskolan-reader .fm4-main {
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  background: var(--fm4-background-color);
}

/* Keep space for FM4 Live Edit top bar when logged in */
body.fm4-bibelskolan-reader.fm4-la-docked .bs-sidebar,
body.fm4-bibelskolan-reader.fm4-live-editing .bs-sidebar,
body.fm4-bibelskolan-reader.fm4-live-edit-active .bs-sidebar,
body.fm4-bibelskolan-reader.fm4-has-admin-bar .bs-sidebar {
  top: 52px;
  height: calc(100dvh - 52px);
}

.bs-skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 9999;
  padding: 0.75rem 1.25rem;
  background: var(--fm4-primary-color);
  color: var(--fm4-surface-color);
  font-family: var(--bs-ui-font);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--fm4-global-radius, 8px);
}
.bs-skip-link:focus {
  left: 1rem;
  top: 1rem;
}

/* Mobile Top Bar (hidden on desktop >= 980px) */
.bs-mobile-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 40;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  background: color-mix(in srgb, var(--fm4-surface-color) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--fm4-border-color);
}

.bs-mobile-brand {
  font-family: var(--fm4-heading-font);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--fm4-text-color);
  text-decoration: none;
  letter-spacing: 0.01em;
}

.bs-icon-btn,
.bs-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 36px;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--fm4-border-color);
  border-radius: var(--fm4-global-radius, 8px);
  background: var(--fm4-surface-color);
  color: var(--fm4-text-color);
  font-family: var(--bs-ui-font);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.bs-icon-btn:hover,
.bs-tool-btn:hover {
  border-color: var(--fm4-primary-color);
  color: var(--fm4-primary-color);
}

.bs-drawer-close {
  display: none;
}

.bs-drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 55;
  background: color-mix(in srgb, var(--fm4-text-color) 45%, transparent);
}
:root.dark-mode .bs-drawer-backdrop,
html.dark-mode .bs-drawer-backdrop {
  background: color-mix(in srgb, var(--fm4-background-color) 72%, transparent);
}

/* Light/Dark theme icon visibility */
.bs-icon-sun { display: none; }
.bs-icon-moon { display: inline-flex; }
:root.dark-mode .bs-icon-sun,
html.dark-mode .bs-icon-sun { display: inline-flex; }
:root.dark-mode .bs-icon-moon,
html.dark-mode .bs-icon-moon { display: none; }

/* Main 2-Column Book Shell */
.bs-shell {
  display: grid;
  grid-template-columns: var(--bs-sidebar-w) minmax(0, 1fr);
  min-height: 100dvh;
  background: var(--fm4-background-color);
}

/* Left Academic Sidebar */
.bs-sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--fm4-surface-color);
  border-right: 1px solid var(--fm4-border-color);
  overflow: hidden;
  z-index: 30;
}

.bs-sidebar-head {
  flex-shrink: 0;
  padding: 1.35rem 1.25rem 1rem;
  border-bottom: 1px solid var(--fm4-border-color);
}

.bs-sidebar-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.bs-brand-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: var(--fm4-text-color);
}

.bs-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--fm4-global-radius, 8px);
  background: color-mix(in srgb, var(--fm4-primary-color) 12%, transparent);
  color: var(--fm4-primary-color);
  flex-shrink: 0;
}

.bs-brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.bs-brand-title {
  font-family: var(--fm4-heading-font);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.15;
  color: var(--fm4-text-color);
}

.bs-brand-sub {
  font-family: var(--bs-ui-font);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--fm4-text-color) 58%, transparent);
  margin-top: 0.12rem;
}

.bs-tools-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 1rem;
}

.bs-font-controls {
  display: inline-flex;
  gap: 0.3rem;
}

.bs-font-controls .bs-tool-btn {
  min-width: 36px;
  padding: 0.3rem 0.5rem;
  font-size: 0.78rem;
}

.bs-progress-wrap {
  margin-top: 0.9rem;
}

.bs-progress-meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--bs-ui-font);
  font-size: 0.74rem;
  color: color-mix(in srgb, var(--fm4-text-color) 64%, transparent);
  margin-bottom: 0.35rem;
}

.bs-progress-track {
  height: 5px;
  width: 100%;
  border-radius: 999px;
  background: color-mix(in srgb, var(--fm4-text-color) 10%, transparent);
  overflow: hidden;
}

.bs-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--fm4-primary-color);
  border-radius: 999px;
  transition: width 0.28s ease;
}

/* Scrollable Study Tree */
.bs-sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.75rem 0.85rem 2rem;
  scrollbar-width: thin;
}

.bs-study-group {
  margin-bottom: 0.3rem;
}

.bs-study-summary,
.bs-study-link {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.65rem;
  border-radius: var(--fm4-global-radius, 8px);
  font-family: var(--bs-ui-font);
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--fm4-text-color);
  text-decoration: none;
  cursor: pointer;
  list-style: none;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.bs-study-summary::-webkit-details-marker {
  display: none;
}

.bs-study-summary:hover,
.bs-study-link:hover {
  background: color-mix(in srgb, var(--fm4-primary-color) 8%, transparent);
}

.bs-study-group.is-current-study > .bs-study-summary {
  background: color-mix(in srgb, var(--fm4-primary-color) 10%, transparent);
  color: var(--fm4-primary-color);
}

.bs-study-link.is-active {
  background: color-mix(in srgb, var(--fm4-primary-color) 14%, transparent);
  color: var(--fm4-primary-color);
}

.bs-roman {
  flex-shrink: 0;
  min-width: 1.75rem;
  font-family: var(--fm4-heading-font);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--fm4-primary-color);
  letter-spacing: 0.03em;
}

.bs-study-name {
  flex: 1 1 auto;
  min-width: 0;
}

.bs-study-count {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 500;
  color: color-mix(in srgb, var(--fm4-text-color) 48%, transparent);
}

.bs-chev {
  flex-shrink: 0;
  color: color-mix(in srgb, var(--fm4-text-color) 48%, transparent);
  transition: transform 0.18s ease;
}

.bs-study-group[open] > .bs-study-summary .bs-chev {
  transform: rotate(180deg);
}

.bs-chapter-list {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  padding: 0.25rem 0 0.45rem 1.35rem;
  margin-left: 0.85rem;
  border-left: 1px solid var(--fm4-border-color);
}

.bs-ch-subgroup-label {
  font-family: var(--bs-ui-font);
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--fm4-text-color) 52%, transparent);
  padding: 0.55rem 0.5rem 0.2rem;
}

.bs-chapter-link {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.38rem 0.55rem;
  border-radius: calc(var(--fm4-global-radius, 8px) * 0.75);
  font-family: var(--bs-ui-font);
  font-size: 0.81rem;
  line-height: 1.38;
  color: color-mix(in srgb, var(--fm4-text-color) 80%, transparent);
  text-decoration: none;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.bs-chapter-link:hover {
  background: color-mix(in srgb, var(--fm4-primary-color) 8%, transparent);
  color: var(--fm4-text-color);
}

.bs-chapter-link.is-active {
  background: color-mix(in srgb, var(--fm4-primary-color) 14%, transparent);
  color: var(--fm4-primary-color);
  font-weight: 600;
}

.bs-ch-num {
  flex-shrink: 0;
  min-width: 1.25rem;
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  color: color-mix(in srgb, var(--fm4-text-color) 48%, transparent);
}

.bs-chapter-link.is-active .bs-ch-num {
  color: var(--fm4-primary-color);
}

.bs-ch-name {
  flex: 1 1 auto;
  min-width: 0;
}

.bs-read-dot {
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: transparent;
  align-self: center;
}

.is-read > .bs-read-dot {
  background: var(--fm4-primary-color);
}

/* Sidebar Author Link (below 10-study curriculum) */
.bs-sidebar-about {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--fm4-border-color);
}

.bs-about-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--fm4-global-radius, 8px);
  text-decoration: none;
  color: var(--fm4-text-color);
  transition: background-color 0.14s ease, color 0.14s ease;
}

.bs-about-nav-link:hover {
  background: color-mix(in srgb, var(--fm4-primary-color) 8%, transparent);
}

.bs-about-nav-link.is-active {
  background: color-mix(in srgb, var(--fm4-primary-color) 14%, transparent);
  color: var(--fm4-primary-color);
}

.bs-about-nav-kicker {
  font-family: var(--bs-ui-font);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fm4-primary-color);
}

.bs-about-nav-name {
  font-family: var(--fm4-heading-font);
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.25;
}

/* Author Portrait & Footnote Card */
.bs-author-figure {
  float: right;
  width: min(230px, 40%);
  margin: 0.25rem 0 1.25rem 1.75rem;
  padding: 0.5rem;
  border: 1px solid var(--fm4-border-color);
  border-radius: var(--fm4-global-radius, 8px);
  background: var(--fm4-surface-color);
}

.bs-author-figure img {
  display: block;
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: 52% 18%;
  border-radius: calc(var(--fm4-global-radius, 8px) * 0.65);
}

.bs-author-figure figcaption {
  margin-top: 0.5rem;
  font-family: var(--bs-ui-font);
  font-size: 0.74rem;
  line-height: 1.4;
  color: color-mix(in srgb, var(--fm4-text-color) 62%, transparent);
}

.bs-author-sources {
  clear: both;
  margin-top: 2rem;
  padding: 1.25rem 1.4rem;
  border: 1px solid var(--fm4-border-color);
  border-left: 3px solid var(--fm4-primary-color);
  border-radius: var(--fm4-global-radius, 8px);
  background: color-mix(in srgb, var(--fm4-surface-color) 88%, var(--fm4-primary-color) 5%);
}

.bs-author-sources h3 {
  margin: 0 0 0.7rem !important;
  font-size: 1.15em !important;
  color: var(--fm4-primary-color) !important;
}

.bs-author-sources ul {
  margin: 0 !important;
  padding-left: 1.25em !important;
}

.bs-author-sources a {
  color: var(--fm4-primary-color);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.bs-author-quote {
  margin: 1.4rem 0;
  padding: 0.9rem 1.25rem;
  border-left: 2px solid var(--fm4-border-color);
  font-style: italic;
  color: color-mix(in srgb, var(--fm4-text-color) 84%, transparent);
}

.bs-colophon-footnote {
  max-width: 56ch;
  margin: 0 auto 1.1rem;
  padding: 0.9rem 1.15rem;
  border: 1px solid var(--fm4-border-color);
  border-radius: var(--fm4-global-radius, 8px);
  background: color-mix(in srgb, var(--fm4-surface-color) 82%, transparent);
  font-family: var(--bs-ui-font);
  font-size: 0.8rem;
  line-height: 1.55;
  color: color-mix(in srgb, var(--fm4-text-color) 74%, transparent);
  text-align: left;
}

.bs-colophon-footnote strong {
  color: var(--fm4-text-color);
  font-weight: 600;
}

.bs-colophon-footnote a {
  color: var(--fm4-primary-color);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}

.bs-colophon-footnote a:hover {
  text-decoration: underline;
}

@media (max-width: 640px) {
  .bs-author-figure {
    float: none;
    width: min(240px, 78%);
    margin: 0 auto 1.4rem;
  }
}

/* Right Reading Column */
.bs-reader-column {
  min-width: 0;
  display: flex;
  justify-content: center;
  padding: var(--fm4-page-title-top-gap, 3.25rem) clamp(1.25rem, 4vw, 3.5rem) var(--fm4-section-gap, 3.5rem);
}

.bs-article {
  width: 100%;
  max-width: var(--bs-measure);
  min-width: 0;
}

.bs-article-header {
  padding-bottom: 1.5rem;
  margin-bottom: var(--fm4-content-gap, 2.25rem);
  border-bottom: 1px solid var(--fm4-border-color);
}

.bs-kicker {
  font-family: var(--bs-ui-font);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--fm4-primary-color);
  margin-bottom: 0.65rem;
}

.bs-sep {
  margin: 0 0.4rem;
  opacity: 0.55;
}

.bs-chapter-title {
  font-family: var(--fm4-heading-font);
  font-size: clamp(2rem, 3.6vw, 2.85rem);
  font-weight: 600;
  line-height: 1.16;
  letter-spacing: -0.01em;
  color: var(--fm4-text-color);
  margin: 0 0 var(--fm4-heading-gap, 1.15rem);
  text-wrap: balance;
}

.bs-meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.2rem;
  font-family: var(--bs-ui-font);
  font-size: 0.82rem;
  color: color-mix(in srgb, var(--fm4-text-color) 62%, transparent);
}

a.bs-author-meta {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--fm4-text-color) 28%, transparent);
  text-underline-offset: 3px;
  transition: color 0.14s ease, text-decoration-color 0.14s ease;
}

a.bs-author-meta:hover {
  color: var(--fm4-primary-color);
  text-decoration-color: var(--fm4-primary-color);
}

.bs-mark-read-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--fm4-border-color);
  border-radius: var(--fm4-global-radius, 8px);
  background: var(--fm4-surface-color);
  color: var(--fm4-text-color);
  font-family: var(--bs-ui-font);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.bs-mark-read-btn:hover {
  border-color: var(--fm4-primary-color);
  color: var(--fm4-primary-color);
}

.bs-mark-read-btn.is-marked {
  background: var(--fm4-primary-color);
  border-color: var(--fm4-primary-color);
  color: var(--fm4-surface-color);
}

/* Academic Prose Slot (wraps FM4 text_block) */
.bs-prose-slot {
  font-family: var(--fm4-body-font);
  font-size: calc(1.125rem * var(--bs-font-scale));
  line-height: 1.78;
  color: var(--fm4-text-color);
  text-wrap: pretty;
}

.bs-prose-slot .uv-content,
.bs-prose-slot .fm4-block-wrap,
.bs-prose-slot .fm4-block-text,
.bs-prose-slot .fm4-text-block,
.bs-prose-slot .fm4-prose,
.bs-prose-slot .fm4-text-content {
  padding: 0 !important;
  margin: 0 !important;
  max-width: none !important;
  background: transparent !important;
}

body:not(.fm4-live-editing) .bs-prose-slot .uv-content,
body:not(.fm4-live-editing) .bs-prose-slot .fm4-block-wrap,
body:not(.fm4-live-editing) .bs-prose-slot .fm4-block-text,
body:not(.fm4-live-editing) .bs-prose-slot .fm4-text-block,
body:not(.fm4-live-editing) .bs-prose-slot .fm4-prose,
body:not(.fm4-live-editing) .bs-prose-slot .fm4-text-content {
  border: none !important;
  box-shadow: none !important;
}

.bs-prose-slot p {
  margin: 0 0 1.25em;
}

.bs-prose-slot p.has-dropcap::first-letter {
  float: left;
  font-family: var(--fm4-heading-font);
  font-size: 3.45em;
  line-height: 0.84;
  font-weight: 600;
  padding-right: 0.12em;
  padding-top: 0.06em;
  color: var(--fm4-primary-color);
}

.bs-prose-slot h2,
.bs-prose-slot h3,
.bs-prose-slot .prose-subhead {
  font-family: var(--fm4-heading-font);
  font-size: 1.48em;
  font-weight: 600;
  line-height: 1.25;
  color: var(--fm4-text-color);
  margin: 2.1em 0 0.7em;
  text-wrap: balance;
}

.bs-prose-slot .prose-section-label {
  font-family: var(--bs-ui-font);
  font-size: 0.82em;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fm4-primary-color);
  margin: 2.2em 0 0.75em;
  padding-top: 1.15em;
  border-top: 1px solid var(--fm4-border-color);
}

.bs-prose-slot ul,
.bs-prose-slot ol,
.bs-prose-slot .academic-list {
  margin: 0.9em 0 1.4em;
  padding-left: 1.45em;
}

.bs-prose-slot li {
  margin-bottom: 0.45em;
}

.bs-prose-slot li::marker {
  color: var(--fm4-primary-color);
}

.bs-prose-slot hr,
.bs-prose-slot .academic-divider {
  border: 0;
  height: 1px;
  background: var(--fm4-border-color);
  margin: 2.2em auto;
  max-width: 14rem;
}

.bs-prose-slot .application-callout {
  margin-top: 2.25rem;
  padding: 1.35rem 1.5rem;
  border-left: 3px solid var(--fm4-primary-color);
  border-radius: var(--fm4-global-radius, 8px);
  background: color-mix(in srgb, var(--fm4-surface-color) 85%, var(--fm4-primary-color) 6%);
  border-top: 1px solid var(--fm4-border-color);
  border-right: 1px solid var(--fm4-border-color);
  border-bottom: 1px solid var(--fm4-border-color);
}

.bs-prose-slot .application-callout h3 {
  margin-top: 0;
  font-size: 1.22em;
  color: var(--fm4-primary-color);
}

/* Prev / Next Chapter Pager */
.bs-pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: var(--fm4-section-gap, 3.5rem);
  padding-top: 1.75rem;
  border-top: 1px solid var(--fm4-border-color);
}

.bs-pager-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--fm4-border-color);
  border-radius: var(--fm4-global-radius, 8px);
  background: var(--fm4-surface-color);
  color: var(--fm4-text-color);
  text-decoration: none;
  transition: border-color 0.16s ease, transform 0.16s ease;
}

.bs-pager-card:hover {
  border-color: var(--fm4-primary-color);
  transform: translateY(-1px);
}

.bs-pager-next {
  justify-content: flex-end;
  text-align: right;
}

.bs-pager-arrow {
  font-size: 1.15rem;
  color: var(--fm4-primary-color);
  flex-shrink: 0;
}

.bs-pager-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.bs-pager-body small {
  font-family: var(--bs-ui-font);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--fm4-text-color) 56%, transparent);
  margin-bottom: 0.2rem;
}

.bs-pager-title {
  font-family: var(--fm4-heading-font);
  font-size: 1.08rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--fm4-text-color);
}

.bs-kbd-hint {
  margin-top: 1rem;
  text-align: center;
  font-family: var(--bs-ui-font);
  font-size: 0.76rem;
  color: color-mix(in srgb, var(--fm4-text-color) 52%, transparent);
}

.bs-kbd-hint kbd {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  border: 1px solid var(--fm4-border-color);
  border-radius: calc(var(--fm4-global-radius, 8px) * 0.5);
  background: var(--fm4-surface-color);
  font-family: var(--bs-ui-font);
  font-size: 0.72rem;
}

/* Academic Colophon & Discreet mickelsson.net SVG Logo */
.bs-colophon {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--fm4-border-color);
  text-align: center;
}

.bs-colophon-line {
  font-family: var(--bs-ui-font);
  font-size: 0.8rem;
  color: color-mix(in srgb, var(--fm4-text-color) 60%, transparent);
}

.bs-back-to-top {
  color: var(--fm4-primary-color);
  text-decoration: none;
  font-weight: 600;
}

.bs-back-to-top:hover {
  text-decoration: underline;
}

.bs-colophon-brand {
  margin-top: 1.15rem;
  display: flex;
  justify-content: center;
}

.bs-mnet-link {
  display: inline-flex;
  align-items: center;
  opacity: 0.72;
  transition: opacity 0.16s ease;
}

.bs-mnet-link:hover {
  opacity: 1;
}

.bs-mnet-logo {
  height: 22px;
  width: auto;
  display: block;
}

:root.dark-mode .bs-mnet-logo,
html.dark-mode .bs-mnet-logo {
  filter: invert(1) brightness(1.08);
}

/* Dark-mode sub-box refinement (FM4 Regel 3) */
:root.dark-mode .bs-pager-card,
html.dark-mode .bs-pager-card,
:root.dark-mode .bs-prose-slot .application-callout,
html.dark-mode .bs-prose-slot .application-callout,
:root.dark-mode .bs-author-figure,
html.dark-mode .bs-author-figure,
:root.dark-mode .bs-author-sources,
html.dark-mode .bs-author-sources,
:root.dark-mode .bs-colophon-footnote,
html.dark-mode .bs-colophon-footnote {
  background: color-mix(in srgb, var(--fm4-surface-color) 78%, var(--fm4-background-color));
}

.bs-footer-sentinel {
  display: none;
}

/* Responsive Tablet / Mobile Drawer (< 980px) */
@media (max-width: 979px) {
  .bs-mobile-topbar {
    display: flex;
  }

  .bs-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .bs-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(86vw, 340px);
    height: 100dvh;
    transform: translateX(-104%);
    transition: transform 0.24s ease;
    z-index: 60;
    box-shadow: 8px 0 30px color-mix(in srgb, var(--fm4-text-color) 18%, transparent);
  }

  body.bs-drawer-open .bs-sidebar {
    transform: translateX(0);
  }

  body.bs-drawer-open .bs-drawer-backdrop {
    display: block;
  }

  body.bs-drawer-open {
    overflow: hidden;
  }

  .bs-drawer-close {
    display: inline-flex;
  }

  .bs-reader-column {
    padding: 1.75rem 1.15rem 2.75rem;
  }

  .bs-pager {
    grid-template-columns: minmax(0, 1fr);
  }

  .bs-kbd-hint {
    display: none;
  }
}

@media print {
  .bs-mobile-topbar,
  .bs-sidebar,
  .bs-drawer-backdrop,
  .bs-mark-read-btn,
  .bs-pager,
  .bs-kbd-hint {
    display: none !important;
  }

  .bs-shell {
    display: block;
  }

  .bs-reader-column {
    padding: 0;
  }

  .bs-article {
    max-width: none;
  }
}
