:root{
  --mbe-ink:#111827;
  --mbe-bg:#ffffff;
  --mbe-soft:#f6f8f7;
  --mbe-gold:#c9a44c;
  --mbe-gold-dark:#946f24;
  --mbe-teal:#2f7d7a;
  --mbe-navy:#0b1f3a;
  --mbe-rule:#e5e0d6;
  --mbe-muted:#5f6673;
  --mbe-ivory:#f7f3e8;
  --mbe-max:1180px;
  --mbe-header-height:112px;
  --mbe-accent:var(--mbe-gold);
  --mbe-accent-dark:var(--mbe-gold-dark);
  --mbe-font-display:"Cormorant Garamond",Georgia,serif;
  --mbe-font-reading:"Literata",Georgia,serif;
  --mbe-font-ui:"Inter",system-ui,sans-serif;
}

.mbe-global-shell *,
.mbe-global-footer *{box-sizing:border-box;}

.mbe-global-shell[data-tool="hermeneutics"],
.mbe-global-footer[data-tool="hermeneutics"]{--mbe-accent:#6b54b3;--mbe-accent-dark:#4b3b87;}
.mbe-global-shell[data-tool="psalms"],
.mbe-global-footer[data-tool="psalms"]{--mbe-accent:#2f7d7a;--mbe-accent-dark:#9b7628;}
.mbe-global-shell[data-tool="daniel"],
.mbe-global-footer[data-tool="daniel"]{--mbe-accent:#c9a44c;--mbe-accent-dark:#5a7049;}
.mbe-global-shell[data-tool="revelation"],
.mbe-global-footer[data-tool="revelation"]{--mbe-accent:#c1564f;--mbe-accent-dark:#8a2f3a;}
.mbe-global-shell[data-tool="sanctuary"],
.mbe-global-footer[data-tool="sanctuary"]{--mbe-accent:#c9a44c;--mbe-accent-dark:#36432f;}
.mbe-global-shell[data-tool="last-day-events"],
.mbe-global-footer[data-tool="last-day-events"]{--mbe-accent:#3f5f86;--mbe-accent-dark:#283a54;}

body.mbe-unified-page{--mbe-local-accent:var(--mbe-accent);}

.mbe-global-shell{
  position:sticky;
  top:0;
  z-index:1000;
  background:rgba(255,255,255,.96);
  border-bottom:1px solid var(--mbe-rule);
  box-shadow:0 18px 40px -36px rgba(11,31,58,.55);
  backdrop-filter:blur(16px);
  font-family:var(--mbe-font-ui);
  color:var(--mbe-ink);
}

.mbe-shell-wrap{
  max-width:var(--mbe-max);
  margin:0 auto;
  padding:0 28px;
}

.mbe-shell-main{
  min-height:76px;
  display:grid;
  grid-template-columns:auto minmax(120px,1fr) auto;
  align-items:center;
  gap:22px;
}

.mbe-brand-lockup{
  display:inline-flex;
  align-items:center;
  min-width:0;
  color:inherit;
  text-decoration:none;
}

.mbe-brand-logo{
  display:block;
  width:clamp(170px,18vw,228px);
  height:auto;
}

.mbe-site-context{
  display:flex;
  flex-direction:column;
  gap:2px;
  min-width:0;
}

.mbe-back-home{
  color:var(--mbe-muted);
  font-size:.7rem;
  font-weight:700;
  letter-spacing:.14em;
  line-height:1.2;
  text-decoration:none;
  text-transform:uppercase;
}

.mbe-back-home:hover{color:var(--mbe-accent-dark);}

.mbe-current-site{
  color:var(--mbe-ink);
  font-family:var(--mbe-font-display);
  font-size:1.24rem;
  font-weight:700;
  line-height:1.08;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.mbe-current-site::before{
  content:"";
  display:inline-block;
  width:.46rem;
  height:.46rem;
  margin-right:.48rem;
  border-radius:50%;
  background:var(--mbe-accent);
  vertical-align:.13rem;
}

.mbe-global-nav{
  display:flex;
  align-items:center;
  gap:18px;
  justify-content:flex-end;
  background:transparent;
  border:0;
  font-size:.88rem;
  font-weight:700;
}

.mbe-global-nav a,
.mbe-library-toggle{
  color:var(--mbe-muted);
  text-decoration:none;
  transition:color .18s ease;
  white-space:nowrap;
}

.mbe-global-nav a:hover,
.mbe-library-menu[open] .mbe-library-toggle,
.mbe-library-toggle:hover{color:var(--mbe-accent-dark);}

.mbe-library-menu{position:relative;}
.mbe-library-toggle{list-style:none;cursor:pointer;}
.mbe-library-toggle::-webkit-details-marker{display:none;}

.mbe-library-toggle::after{
  content:"";
  display:inline-block;
  width:.42rem;
  height:.42rem;
  margin-left:.42rem;
  border-right:1.5px solid currentColor;
  border-bottom:1.5px solid currentColor;
  transform:rotate(45deg) translateY(-.12rem);
}

.mbe-library-menu[open] .mbe-library-toggle::after{
  transform:rotate(225deg) translateY(-.12rem);
}

.mbe-library-panel{
  position:absolute;
  right:0;
  top:calc(100% + 14px);
  width:min(920px,calc(100vw - 32px));
  max-height:calc(100vh - 96px);
  overflow:auto;
  overscroll-behavior:contain;
  padding:12px;
  border:1px solid var(--mbe-rule);
  border-radius:8px;
  background:#fff;
  color:var(--mbe-ink);
  box-shadow:0 24px 50px -34px rgba(11,31,58,.55);
}

.mbe-library-panel::before{
  content:"";
  position:absolute;
  top:-18px;
  right:0;
  left:0;
  height:18px;
}

.mbe-library-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:6px;
}

.mbe-library-item{
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:2px;
  padding:11px 12px;
  border-radius:6px;
  color:var(--mbe-ink);
  text-decoration:none;
}

.mbe-library-item:hover{background:var(--mbe-soft);}
.mbe-library-item[aria-current="page"]{background:rgba(201,164,76,.13);}
.mbe-library-name{font-family:var(--mbe-font-display);font-size:1.02rem;font-weight:700;line-height:1.1;}
.mbe-library-desc{color:var(--mbe-muted);font-size:.78rem;font-weight:500;line-height:1.35;overflow-wrap:anywhere;}

.mbe-tool-row{
  border-top:1px solid rgba(229,224,214,.78);
  min-height:36px;
  display:flex;
  align-items:center;
}

.mbe-tool-nav{
  width:100%;
  display:flex;
  align-items:center;
  gap:8px;
  overflow-x:auto;
  padding:8px 0;
  scrollbar-width:none;
}

.mbe-tool-nav::-webkit-scrollbar{display:none;}

.mbe-tool-link{
  flex:0 0 auto;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:28px;
  padding:6px 12px;
  border:1px solid transparent;
  border-radius:999px;
  background:transparent;
  color:var(--mbe-muted);
  font:700 .72rem/1 var(--mbe-font-ui);
  letter-spacing:.08em;
  text-transform:uppercase;
  text-decoration:none;
  cursor:pointer;
  transition:background .18s ease,border-color .18s ease,color .18s ease;
}

.mbe-tool-link:hover,
.mbe-tool-link.active,
.mbe-tool-link[aria-current="page"]{
  border-color:rgba(201,164,76,.44);
  background:rgba(201,164,76,.12);
  color:var(--mbe-accent-dark);
}

.mbe-global-footer{
  order:999;
  background:linear-gradient(180deg,#fffdf8 0%,var(--mbe-ivory) 100%);
  color:var(--mbe-muted);
  font-family:var(--mbe-font-ui);
  border-top:1px solid var(--mbe-rule);
  box-shadow:0 -14px 32px -30px rgba(11,31,58,.42);
  padding:0;
}

.mbe-footer-wrap{
  min-height:auto;
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  justify-content:space-between;
  gap:10px clamp(18px,3vw,34px);
  padding:24px clamp(20px,3vw,42px);
  font-size:clamp(.86rem,.95vw,.98rem);
  line-height:1.4;
}

.mbe-footer-brand{
  display:inline-flex;
  align-items:center;
  flex:0 0 auto;
  color:inherit;
  text-decoration:none;
  border-bottom:0;
}

.mbe-footer-logo{
  display:block;
  width:clamp(168px,16vw,240px);
  max-width:100%;
  height:auto;
}

.mbe-footer-wrap > span:last-child{
  flex-basis:100%;
  color:var(--mbe-muted);
  font-size:clamp(.78rem,.85vw,.9rem);
}

.mbe-footer-link{
  color:var(--mbe-gold-dark);
  text-decoration:none;
  font-weight:700;
  border-bottom:1px solid rgba(155,118,40,.45);
  padding-bottom:2px;
}

.mbe-footer-link:hover{
  color:var(--mbe-navy);
  border-bottom-color:var(--mbe-navy);
}

body:has(> .mbe-global-footer){
  min-height:100vh;
  display:flex;
  flex-direction:column;
}

body:has(> .mbe-global-footer) > main,
body:has(> .mbe-global-footer) > .mbe-global-footer{
  min-width:0;
}

body:has(> .mbe-global-footer) > .mbe-global-footer{
  order:999;
  margin-top:auto;
  flex:0 0 auto;
}

body[data-mbe-tool="daniel"] header.sticky,
body[data-mbe-tool="revelation"] .reader-header,
body[data-mbe-tool="revelation"] > div.fixed.top-0,
body[data-mbe-tool="hermeneutics"] #root header:first-of-type,
body[data-mbe-tool="psalms"] .atlas-top-strip,
body[data-mbe-tool="sanctuary"] .app-shell > .site-header,
body[data-mbe-tool="last-day-events"] > .site-header,
body[data-mbe-tool="last-day-events"] > .site-footer{
  display:none!important;
}

body[data-mbe-tool="daniel"] main,
body[data-mbe-tool="revelation"] main,
body[data-mbe-tool="hermeneutics"] #root,
body[data-mbe-tool="psalms"] .atlas-page,
body[data-mbe-tool="sanctuary"] .app-shell,
body[data-mbe-tool="last-day-events"] main{
  font-family:var(--mbe-font-reading);
}

body[data-mbe-tool="daniel"] main h1,
body[data-mbe-tool="daniel"] main h2,
body[data-mbe-tool="daniel"] main h3,
body[data-mbe-tool="revelation"] main h1,
body[data-mbe-tool="revelation"] main h2,
body[data-mbe-tool="revelation"] main h3,
body[data-mbe-tool="last-day-events"] main h1,
body[data-mbe-tool="last-day-events"] main h2,
body[data-mbe-tool="last-day-events"] main h3,
body[data-mbe-tool="sanctuary"] main h1,
body[data-mbe-tool="sanctuary"] main h2,
body[data-mbe-tool="sanctuary"] main h3{
  font-family:var(--mbe-font-display);
}

body[data-mbe-tool="daniel"] .text-primary,
body[data-mbe-tool="revelation"] .text-primary{color:var(--mbe-accent-dark)!important;}

body[data-mbe-tool="daniel"] .bg-primary,
body[data-mbe-tool="revelation"] .bg-primary{background-color:var(--mbe-accent-dark)!important;}

body[data-mbe-tool="psalms"] .atlas-page{
  height:calc(100vh - var(--mbe-header-height));
  background:linear-gradient(180deg,#fff,#f6f8f7);
}

body[data-mbe-tool="psalms"] .atlas-main{scroll-padding-top:24px;}
body[data-mbe-tool="psalms"] .atlas-brand-title{font-family:var(--mbe-font-display);}

body[data-mbe-tool="sanctuary"] .app-shell,
body[data-mbe-tool="last-day-events"] .page{
  min-height:auto;
}

@media(max-width:900px){
  :root{--mbe-header-height:142px;}
  .mbe-shell-main{grid-template-columns:1fr auto;gap:14px;min-height:70px;}
  .mbe-site-context{display:none;}
  .mbe-brand-logo{width:174px;}
  .mbe-global-nav{gap:12px;font-size:.82rem;}
  .mbe-library-panel{right:-80px;}
  .mbe-library-grid{grid-template-columns:1fr;}
}

@media(max-width:620px){
  :root{--mbe-header-height:180px;}
  .mbe-shell-wrap{padding:0 16px;}
  .mbe-shell-main{grid-template-columns:1fr;align-items:start;padding-top:10px;padding-bottom:8px;}
  .mbe-brand-logo{width:166px;}
  .mbe-global-nav{width:100%;justify-content:space-between;gap:10px;}
  .mbe-library-panel{left:0;right:auto;width:calc(100vw - 32px);}
  .mbe-footer-wrap{align-items:flex-start;flex-direction:column;gap:12px;padding:28px 20px;}
}
