

.bmh-anchor {
  --bmh-lift: -1.15rem;

  position: sticky; top: 0; z-index: 42; flex: none; height: 0;
  display: flex; justify-content: flex-end; pointer-events: none;
}
.bmh-btn {
  pointer-events: auto; transform: translateY(var(--bmh-lift));
  flex: none; width: 26px; height: 26px; padding: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--rule2); background: var(--surface); color: var(--muted);
  font: inherit; font-size: .84rem; font-weight: 700; line-height: 1; cursor: pointer;
  box-shadow: var(--shadow); transition: background .15s, border-color .15s, color .15s;
}
.bmh-btn:hover, .bmh-btn[aria-expanded="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.bmh-btn:focus-visible { outline: 2px solid var(--brand-bright); outline-offset: 2px; }

#reading > .bmh-anchor { top: calc(var(--topbar-h, 56px) + var(--ws-tabs-h, 46px) + .35rem); --bmh-lift: 0rem; }

#panel-edit:has(> .ed-paper-wrap) > .bmh-anchor { --bmh-lift: -.5rem; }

.bmh-sheet {
  position: fixed; z-index: 62; box-sizing: border-box;
  top: calc(var(--topbar-h, 56px) + var(--ws-tabs-h, 46px)); right: 0; bottom: 0;
  width: min(370px, 92vw);
  display: flex; flex-direction: column;
  background: var(--surface); color: var(--text);
  border-left: 1px solid var(--rule); box-shadow: var(--shadow);
  transform: translateX(100%); transition: transform .18s ease-out;
}
.bmh-sheet.on { transform: none; }

.bmh-top {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  padding: .7rem .9rem .55rem; border-bottom: 1px solid var(--rule);
}
.bmh-tag { font-size: .68rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); }
.bmh-x {
  appearance: none; border: 0; background: none; color: var(--muted);
  font-size: 1.2rem; line-height: 1; padding: .15rem .4rem; border-radius: 8px; cursor: pointer;
}
.bmh-x:hover { color: var(--text); background: var(--surface2); }

.bmh-body {
  flex: 1; min-height: 0; overflow-y: auto; padding: 1rem .95rem 1.6rem;
  scrollbar-gutter: stable; scrollbar-width: thin; scrollbar-color: transparent transparent;
}
.bmh-body:hover, .bmh-body:focus-within { scrollbar-color: color-mix(in srgb, var(--muted) 60%, transparent) transparent; }
.bmh-body::-webkit-scrollbar { width: 12px; background: transparent; }
.bmh-body::-webkit-scrollbar-track { background: transparent; }
.bmh-body::-webkit-scrollbar-thumb { background-color: transparent; background-clip: padding-box;
  border: 3px solid transparent; border-radius: 999px; min-height: 40px; }
.bmh-body:hover::-webkit-scrollbar-thumb { background-color: color-mix(in srgb, var(--muted) 60%, transparent); }

.bmh-eyebrow { margin: 0 0 .25rem; font-size: .7rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--brand); }
.bmh-title { font-family: var(--serif, Georgia, serif); font-weight: 600; font-size: 1.28rem;
  margin: 0 0 .55rem; text-wrap: balance; }
.bmh-title:focus-visible { outline: 2px solid var(--brand-bright); outline-offset: 3px; border-radius: 6px; }
.bmh-p { margin: 0 0 1rem; color: var(--muted); font-size: .92rem; line-height: 1.6; text-wrap: pretty; }
.bmh-walk { width: 100%; }

.bmh-rel-h { margin: 1.6rem 0 .5rem; font-size: .72rem; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--faint); }
.bmh-rel { display: flex; flex-wrap: wrap; gap: .4rem; }
.bmh-rel-b {
  font: inherit; font-size: .84rem; font-weight: 600; text-align: left; cursor: pointer;
  padding: .38rem .7rem; border-radius: 999px;
  border: 1px solid var(--rule2); background: var(--surface); color: var(--text);
}
.bmh-rel-b:hover { border-color: var(--brand-bright); color: var(--brand-ink); }
.bmh-rel-b:focus-visible { outline: 2px solid var(--brand-bright); outline-offset: 2px; }

.bmh-rel-b.bmh-off { opacity: .55; }

@media (max-width: 700px) {
  .bmh-sheet {
    top: auto; left: 0; right: 0; bottom: 0; width: auto;
    max-height: min(62vh, 30rem);
    border-left: 0; border-top: 1px solid var(--rule); border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }
  .bmh-sheet.on { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .bmh-sheet { transition: none; }
}
