/* === Brain Dump: RIGHT RAIL list/grid only === */
/* Scope: #rightRail and .apoth-main contexts (kept for parity) */

/* Neutralize foreign rail layouts when any right-rail grid exists */
#rightRail:has(.rc-rail-grid),
.apoth-main #rightRail,
#mainContainer.apoth-main #rightRail{
  display: block !important;
}

/* Align the rail chip grid with the top of the first section */
#rightRail #journalButtons{
  margin-top: 3.25rem !important; /* visually matches card top */
}

/* Ensure right-rail rail-grid is actually a grid even without .rc-wrap */
#rightRail .rc-rail-grid{
  display: grid !important;
  grid-template-columns: repeat(12, minmax(0, 1fr)) !important;
  gap: 0.75rem !important;
  row-gap: 0.75rem !important;
  column-gap: 0.75rem !important;
  grid-auto-rows: 8px;
  align-items: start !important;
}

/* If there is an intermediate wrapper between the rail grid and the chips,
   give THAT wrapper spacing so pills never touch. */
#rightRail .rc-rail-grid > :is(div, section, nav, article):has(.hub-btn, .vm-link){
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 0.75rem !important;
  align-items: flex-start !important;
}

/* Bootstrap btn-group wrapper also needs spacing when used for chips */
#rightRail .rc-rail-grid > .btn-group:has(.hub-btn, .vm-link){
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 0.75rem !important;
}

/* --- Right rail: neutralize Bootstrap btn-group compaction everywhere --- */
#rightRail .btn-group:has(.hub-btn, .vm-link){
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: flex-start !important;
  gap: 0.75rem !important;
}

/* Kill Bootstrap’s negative margin joiners that remove spacing */
#rightRail .btn-group > .btn:not(:first-child),
#rightRail .btn-group > .btn-group:not(:first-child){
  margin-left: 0 !important;
}

/* Avoid double spacing: inside btn-group, use container gap only */
#rightRail .btn-group .hub-btn,
#rightRail .btn-group .vm-link,
#rightRail .btn-group .btn{
  margin: 0 !important;
  width: auto !important;
  max-width: 100% !important;
  white-space: nowrap !important;
}

/* Provide minimal external whitespace so pills never touch even if a grid isn't applied yet */
#rightRail .rc-rail-grid .hub-btn{
  margin: 0.375rem !important;
}

/* Desktop: 3-up rail cards */
@media (min-width: 992px){
  .rc-wrap .rc-rail-grid > .rc-card{
    grid-column: span 4;
  }
}

/* HARD STOP: right-rail buttons never stretch full width */
#rightRail .journal-pill,
#rightRail .hub-btn,
#rightRail .btn.hub-btn{
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: auto !important;
  max-width: 100% !important;
  white-space: nowrap !important;
  justify-self: start !important;
  background: #fff !important;
  border: 1px solid var(--brand-gold, #b08a48) !important;
  border-radius: 0.5rem !important;
  color: #000 !important;
  font-family: var(--bs-body-font-family,"Montserrat",system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial) !important;
  font-size: 0.84rem !important;
  line-height: 1.2 !important;
  min-height: 30px !important;
  margin: 0.375rem !important;
  box-sizing: border-box !important;
}

/* Brain Dump pills as direct children of the rail grid:
   enforce 2-up on mobile (span 6) and 3-up on lg+ (span 4). */
#rightRail #journalButtons > .journal-pill{
  grid-column: span 6 !important;
}
@media (min-width: 992px){
  #rightRail #journalButtons > .journal-pill{
    grid-column: span 4 !important;
  }
}

/* Unified brick grid for any lists rendered in the right rail */
#rightRail ul,
#rightRail .vm-list{
  display: grid !important;
  grid-template-columns: repeat(12, minmax(0, 1fr)) !important;
  padding: 0 !important;
  gap: 0.75rem !important;
  row-gap: 0.75rem !important;
  column-gap: 0.75rem !important;
  align-items: start !important;
  grid-auto-flow: row dense !important;
}

/* Items: 2-up on mobile (span 6), 3-up on lg+ (span 4) */
#rightRail ul > li,
#rightRail .vm-list > li{
  list-style: none;
  margin: 0;
  padding: 0;
  grid-column: span 6 !important;
  break-inside: avoid;
}
@media (min-width: 992px){
  #rightRail ul > li,
  #rightRail .vm-list > li{
    grid-column: span 4 !important;
  }
}

/* Links/pills inside rail items: never stretch; spacing from grid only */
#rightRail ul > li > .vm-link,
#rightRail ul > li > .hub-btn,
#rightRail .vm-list > li > .vm-link,
#rightRail .vm-list > li > .hub-btn{
  display: inline-flex !important;
  width: auto !important;
  max-width: 100% !important;
  white-space: nowrap !important;
  justify-self: start !important;
  margin: 0.375rem !important;
}

/* Any UL inside right rail becomes a 12-col grid */
.apoth-main #rightRail .rc-wrap ul{
  display: grid !important;
  grid-template-columns: repeat(12, minmax(0, 1fr)) !important;
  padding: 0 !important;
  gap: 0.75rem !important;
  row-gap: 0.75rem !important;
  column-gap: 0.75rem !important;
  align-items: start !important;
  grid-auto-flow: row dense !important;
}

/* Items inside those ULs: 2-up mobile, 3-up on lg+ */
.apoth-main #rightRail .rc-wrap ul > li{
  list-style: none;
  margin: 0;
  padding: 0;
  grid-column: span 6 !important;
  break-inside: auto;
}
@media (min-width: 992px){
  .apoth-main #rightRail .rc-wrap ul > li{
    grid-column: span 4 !important;
  }
}

/* Prevent stretch for links/buttons in those items */
.apoth-main #rightRail .rc-wrap ul > li > .vm-link,
.apoth-main #rightRail .rc-wrap ul > li > .hub-btn{
  display: inline-flex !important;
  width: auto !important;
  max-width: 100% !important;
  white-space: nowrap !important;
  justify-self: start !important;
}

/* FINAL WORD: enforce the 0.75rem spacing on any right-rail grid */
#rightRail :is(.rc-rail-grid, ul, .vm-list),
.apoth-main #rightRail :is(.rc-rail-grid, ul, .vm-list){
  row-gap: 0.75rem !important;
  column-gap: 0.75rem !important;
  gap: 0.75rem !important;
}

/* Rail cards: width hygiene */
#rightRail .rc-card{
  width: auto;
  max-width: 100%;
}

/* FINAL LOCKS: prevent any stretch inside the right rail */
#rightRail :is(.journal-pill, .hub-btn, .btn.hub-btn, .btn, .vm-link){
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: auto !important;
  max-width: 100% !important;
  white-space: nowrap !important;
  justify-self: start !important;
  margin: 0.375rem !important;
  box-sizing: border-box !important;
}

/* Safety: if a plain list/container lands without our grid, keep it non-fullwidth */
#rightRail :is(ol, ul):not(.vm-list){
  display: grid !important;
  grid-template-columns: repeat(12, minmax(0, 1fr)) !important;
  gap: 0.75rem !important;
  padding: 0 !important;
  align-items: start !important;
  grid-auto-flow: row dense !important;
}
#rightRail :is(ol, ul):not(.vm-list) > li{
  list-style: none;
  margin: 0;
  padding: 0;
  grid-column: span 6 !important;
  break-inside: avoid;
}
@media (min-width: 992px){
  #rightRail :is(ol, ul):not(.vm-list) > li{
    grid-column: span 4 !important;
  }
}

/* Safety: card*
