/**
 * Brand Bridge — shared practice toolbar + notation ads (song + sargam).
 * Phase 4: selectors under body.kp-bb-song / body.kp-bb-sargam.
 * Sheet bg: --sheet-head (song) or --bb-sheet-bg (sargam).
 */

/* Practice toolbar — pinned to viewport bottom while notes are on screen */
:is(body.kp-bb-song, body.kp-bb-sargam) #music-toolbar.kp-practice-toolbar,
:is(body.kp-bb-song, body.kp-bb-sargam) #music-toolbar,
:is(body.kp-bb-song, body.kp-bb-sargam) .kp-song__toolbar {
  order: 3;
  position: relative !important;
  top: auto !important;
  bottom: auto !important;
  z-index: 5;
  display: flex !important;
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  gap: 0 !important;
  width: calc(100% + 1.7rem) !important;
  max-width: none !important;
  margin: 0 -0.85rem !important;
  padding: 0 !important;
  box-sizing: border-box !important;
  border-radius: 0 !important;
  border: 0 !important;
  border-top: 3px solid var(--bb-accent) !important;
  background: var(--sheet-head, var(--bb-sheet-bg, #fdfbf7)) !important;
  color: var(--bb-text) !important;
  box-shadow: 0 -6px 20px rgba(15, 23, 42, 0.08) !important;
  font-family: var(--bb-font) !important;
}

:is(body.kp-bb-song, body.kp-bb-sargam) #music-toolbar.kp-song__toolbar--pinned,
:is(body.kp-bb-song, body.kp-bb-sargam) .kp-song__toolbar--pinned {
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  z-index: 120 !important;
  border-top: 3px solid var(--bb-accent) !important;
  background: color-mix(in srgb, var(--bb-surface) 96%, transparent) !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 -10px 32px rgba(15, 23, 42, 0.14) !important;
}

:is(body.kp-bb-song, body.kp-bb-sargam) .kp-practice-toolbar__head {
  display: flex !important;
  align-items: center !important;
  gap: 0.5rem !important;
  padding: 0.55rem 0.85rem 0.45rem !important;
  border-bottom: 1px solid var(--bb-border) !important;
  background: color-mix(in srgb, var(--bb-accent) 6%, var(--bb-surface)) !important;
}

:is(body.kp-bb-song, body.kp-bb-sargam) .kp-practice-toolbar__badge {
  display: inline-flex !important;
  align-items: center !important;
  padding: 0.15rem 0.45rem !important;
  border-radius: 999px !important;
  background: var(--bb-accent) !important;
  color: #fff !important;
  font-size: 0.62rem !important;
  font-weight: 800 !important;
  letter-spacing: 0.06em !important;
  text-transform: uppercase !important;
  line-height: 1.2 !important;
}

:is(body.kp-bb-song, body.kp-bb-sargam) .kp-practice-toolbar__title {
  font-size: 0.82rem !important;
  font-weight: 800 !important;
  color: var(--bb-text) !important;
  letter-spacing: -0.02em !important;
}

:is(body.kp-bb-song, body.kp-bb-sargam) .kp-practice-toolbar__body {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.5rem 0.65rem !important;
  padding: 0.6rem 0.85rem calc(0.6rem + env(safe-area-inset-bottom, 0px)) !important;
}

:is(body.kp-bb-song, body.kp-bb-sargam) .kp-practice-toolbar__group {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.4rem !important;
  flex-wrap: wrap !important;
}

:is(body.kp-bb-song, body.kp-bb-sargam) .kp-practice-toolbar__group-label {
  font-size: 0.68rem !important;
  font-weight: 700 !important;
  color: var(--bb-muted) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.05em !important;
}

:is(body.kp-bb-song, body.kp-bb-sargam) .kp-practice-toolbar__transpose,
:is(body.kp-bb-song, body.kp-bb-sargam) .kp-practice-toolbar__font {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.35rem !important;
}

:is(body.kp-bb-song, body.kp-bb-sargam) .kp-practice-toolbar.is-collapsed .kp-practice-toolbar__body {
  display: none !important;
}

:is(body.kp-bb-song, body.kp-bb-sargam) .kp-practice-toolbar.is-collapsed .kp-practice-toolbar__head {
  border-bottom: none !important;
}

:is(body.kp-bb-song, body.kp-bb-sargam) .kp-practice-toolbar__collapse {
  background: var(--bb-surface) !important;
  color: var(--bb-muted) !important;
  border: 1px solid var(--bb-border) !important;
  box-shadow: none !important;
}

:is(body.kp-bb-song, body.kp-bb-sargam) .kp-practice-toolbar__collapse:hover,
:is(body.kp-bb-song, body.kp-bb-sargam) .kp-practice-toolbar__collapse:focus-visible {
  background: var(--bb-surface) !important;
  border-color: var(--bb-accent) !important;
  color: var(--bb-accent) !important;
}

:is(body.kp-bb-song, body.kp-bb-sargam) #music-toolbar.kp-practice-toolbar.is-hidden,
:is(body.kp-bb-song, body.kp-bb-sargam) #music-toolbar.is-hidden {
  display: none !important;
}

body.kp-song--toolbar-pinned.kp-bb-song .kp-song__main,
body.kp-song--toolbar-pinned.kp-bb-song .kp-song__notes,
body.kp-song--toolbar-pinned.kp-bb-sargam .kp-sargam-main {
  padding-bottom: 0;
}

:is(body.kp-bb-song, body.kp-bb-sargam) .kp-song__toolbar-spacer {
  display: none;
  width: 100%;
  height: 0;
  flex: 0 0 auto;
  pointer-events: none;
}

body.kp-song--toolbar-pinned.kp-bb-song .kp-song__toolbar-spacer,
body.kp-song--toolbar-pinned.kp-bb-sargam .kp-song__toolbar-spacer {
  display: block;
  height: 7.5rem;
  order: 4;
}

body.kp-song--toolbar-pinned.kp-bb-song.kp-song--toolbar-collapsed:not(.kp-song--toolbar-hidden) .kp-song__toolbar-spacer,
body.kp-song--toolbar-pinned.kp-bb-sargam.kp-song--toolbar-collapsed:not(.kp-song--toolbar-hidden) .kp-song__toolbar-spacer {
  height: 3.5rem;
}

body.kp-song--toolbar-pinned.kp-bb-song.kp-song--toolbar-hidden .kp-song__toolbar-spacer,
body.kp-song--toolbar-pinned.kp-bb-sargam.kp-song--toolbar-hidden .kp-song__toolbar-spacer {
  height: 0;
}

:is(body.kp-bb-song, body.kp-bb-sargam) .music-toolbar-button {
  min-height: 2.25rem;
  min-width: 2.25rem;
  padding: 0.35rem 0.7rem !important;
  background: var(--bb-surface) !important;
  color: var(--bb-text) !important;
  border: 1px solid var(--bb-border) !important;
  border-radius: 0.5rem !important;
  font-family: var(--bb-font) !important;
  font-size: 0.82rem !important;
  font-weight: 700 !important;
  line-height: 1.2 !important;
  box-shadow: none !important;
}

:is(body.kp-bb-song, body.kp-bb-sargam) .music-toolbar-button:hover {
  border-color: var(--bb-accent) !important;
  color: var(--bb-accent) !important;
  background: var(--bb-surface) !important;
}

:is(body.kp-bb-song, body.kp-bb-sargam) .music-toolbar-button:focus-visible {
  outline: 2px solid var(--bb-accent);
  outline-offset: 1px;
}

:is(body.kp-bb-song, body.kp-bb-sargam) .music-toolbar-select,
:is(body.kp-bb-song, body.kp-bb-sargam) #transpose-meter {
  min-height: 2.25rem;
  padding: 0.35rem 0.65rem !important;
  background: var(--bb-surface) !important;
  color: var(--bb-text) !important;
  border: 1px solid var(--bb-border) !important;
  border-radius: 0.5rem !important;
  font-family: var(--bb-font) !important;
  font-size: 0.82rem !important;
  font-weight: 600 !important;
  box-shadow: none !important;
}

:is(body.kp-bb-song, body.kp-bb-sargam) #transpose-meter {
  min-width: 2.35rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

:is(body.kp-bb-song, body.kp-bb-sargam) .kp-theme-picker__btn,
:is(body.kp-bb-song, body.kp-bb-sargam) .kp-theme-picker__btn--sheet {
  min-height: 2.25rem;
  padding: 0.35rem 0.7rem !important;
  background: var(--bb-surface) !important;
  color: var(--bb-text) !important;
  border: 1px solid var(--bb-border) !important;
  border-radius: 0.5rem !important;
  font-family: var(--bb-font) !important;
  font-size: 0.82rem !important;
  font-weight: 700 !important;
  box-shadow: none !important;
}

:is(body.kp-bb-song, body.kp-bb-sargam) .kp-theme-picker__btn:hover,
:is(body.kp-bb-song, body.kp-bb-sargam) .kp-theme-picker__btn--sheet:hover {
  border-color: var(--bb-accent) !important;
  color: var(--bb-accent) !important;
}

:is(body.kp-bb-song, body.kp-bb-sargam) .music-toolbar-group--theme .music-toolbar__label {
  color: var(--bb-muted);
  font-family: var(--bb-font);
  font-size: 0.75rem;
  font-weight: 700;
}

html[data-theme="dark"] :is(body.kp-bb-song, body.kp-bb-sargam) #music-toolbar,
html[data-theme="dark"] :is(body.kp-bb-song, body.kp-bb-sargam) .kp-song__toolbar,
html[data-theme="dark"] :is(body.kp-bb-song, body.kp-bb-sargam) #music-toolbar.kp-song__toolbar--pinned {
  background: color-mix(in srgb, #1e293b 94%, transparent) !important;
  border-top-color: #334155 !important;
  border-bottom-color: transparent !important;
  color: #f8fafc !important;
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.45) !important;
}

@media (max-width: 767px) {
  :is(body.kp-bb-song, body.kp-bb-sargam) #music-toolbar,
  :is(body.kp-bb-song, body.kp-bb-sargam) #music-toolbar.kp-song__toolbar--pinned {
    z-index: 120 !important;
    padding: 0 !important;
  }

  :is(body.kp-bb-song, body.kp-bb-sargam) .kp-practice-toolbar__body {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.5rem !important;
  }

  :is(body.kp-bb-song, body.kp-bb-sargam) .kp-practice-toolbar__group {
    justify-content: space-between !important;
    width: 100% !important;
  }

  :is(body.kp-bb-song, body.kp-bb-sargam) .kp-practice-toolbar__group[data-group="display"] {
    justify-content: center !important;
  }

  :is(body.kp-bb-song, body.kp-bb-sargam) .kp-practice-toolbar__group[data-group="theme"] {
    flex-wrap: wrap !important;
  }

  :is(body.kp-bb-song, body.kp-bb-sargam) .kp-practice-toolbar__group[data-group="theme"] .music-toolbar-select {
    flex: 1 1 auto !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  :is(body.kp-bb-song, body.kp-bb-sargam) .music-toolbar-button,
  :is(body.kp-bb-song, body.kp-bb-sargam) #transpose-meter,
  :is(body.kp-bb-song, body.kp-bb-sargam) .music-toolbar-select,
  :is(body.kp-bb-song, body.kp-bb-sargam) .kp-theme-picker__btn,
  :is(body.kp-bb-song, body.kp-bb-sargam) .kp-theme-picker__btn--sheet {
    min-height: 44px !important;
    min-width: 44px !important;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  body.kp-song--toolbar-pinned.kp-bb-song .kp-song__toolbar-spacer,
  body.kp-song--toolbar-pinned.kp-bb-sargam .kp-song__toolbar-spacer {
    height: 10rem;
  }
}

/* Panel banner / notation toggle */
:is(body.kp-bb-song, body.kp-bb-sargam) .kp-practice-toolbar-toggle {
  border: 1px solid var(--bb-border) !important;
  background: var(--bb-surface) !important;
  color: var(--bb-text) !important;
  border-radius: 0.5rem !important;
  padding: 0.35rem 0.65rem !important;
  font-family: var(--bb-font) !important;
  font-size: 0.78rem !important;
  font-weight: 700 !important;
  cursor: pointer;
  touch-action: manipulation;
}

body.kp-bb-song .kp-notation__panel-banner .kp-practice-toolbar-toggle {
  margin-left: auto;
}

:is(body.kp-bb-song, body.kp-bb-sargam) .kp-practice-toolbar-toggle:hover {
  border-color: var(--bb-accent) !important;
  color: var(--bb-accent) !important;
}

/* Responsive AdSense — notation top / bottom slots (clamp WIDTH) */
.kp-song__ad--notation-top,
.kp-song__ad--notation-bottom,
.kp-sargam-ad--notation-top,
.kp-sargam-ad--notation-bottom {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
  margin-block: 1.25rem;
  contain: inline-size;
}

/* Inside Notation Box Ads */
.kp-notation-ad--inside {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  margin: 0.75rem 0 1rem !important;
  padding: 0 0.85rem !important;
  text-align: center !important;
  line-height: normal !important;
  font-family: var(--bb-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif) !important;
  background: transparent !important;
  clear: both !important;
  border-radius: 12px !important;
  overflow-x: hidden !important;
  overflow-y: visible !important;
}

@media (max-width: 767px) {
  .kp-notation-ad--inside {
    width: 100% !important;
    margin: 0.5rem 0 0.75rem !important;
    padding: 0 0.5rem !important;
  }
}

.kp-song__ad--notation-bottom.kp-notation-ad--inside,
.kp-sargam-ad--notation-bottom.kp-notation-ad--inside {
  margin: 1.25rem auto 0.75rem !important;
}

.kp-song__ad--notation-top .kp-bb-ad__label,
.kp-song__ad--notation-bottom .kp-bb-ad__label,
.kp-sargam-ad--notation-top .kp-bb-ad__label,
.kp-sargam-ad--notation-bottom .kp-bb-ad__label,
.kp-notation-ad--inside .kp-bb-ad__label {
  display: none;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 0.35rem;
  text-align: center;
  line-height: 1;
}

.kp-notation-ad--inside:has(iframe) .kp-bb-ad__label,
.kp-notation-ad--inside:has(ins[data-ad-status="filled"]) .kp-bb-ad__label,
.kp-notation-ad--inside.is-filled .kp-bb-ad__label {
  display: block !important;
}

.kp-notation-ad--inside:has(ins[data-ad-status="unfilled"]),
.kp-notation-ad--inside:has(ins[style*="display: none"]),
.kp-notation-ad--inside:has(ins[style*="display:none"]),
.kp-notation-ad--inside.is-unfilled {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.kp-song__ad--notation-top .kp-bb-ad__box,
.kp-song__ad--notation-bottom .kp-bb-ad__box,
.kp-sargam-ad--notation-top .kp-bb-ad__box,
.kp-sargam-ad--notation-bottom .kp-bb-ad__box,
.kp-notation-ad--inside .kp-bb-ad__box {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  height: auto !important;
  background: transparent !important;
  border: none !important;
  border-radius: 12px !important;
  overflow-x: hidden !important;
  margin: 0 auto !important;
  box-sizing: border-box !important;
}

.kp-notation-ad--inside .kp-bb-ad__box ins.adsbygoogle {
  display: block !important;
  margin: 0 auto !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  border-radius: 12px !important;
  overflow-x: hidden !important;
  box-sizing: border-box !important;
}

.kp-notation-ad--inside .kp-bb-ad__box ins.adsbygoogle iframe,
.kp-notation-ad--inside .kp-bb-ad__box ins.adsbygoogle > div,
.kp-notation-ad--inside .kp-bb-ad__box ins.adsbygoogle > div > iframe {
  margin: 0 auto !important;
  width: 100% !important;
  max-width: 100% !important;
  border-radius: 12px !important;
  box-sizing: border-box !important;
}

/* Related-search / multiplex creatives can inject wide tables */
.kp-notation-ad--inside .kp-bb-ad__box table,
.kp-notation-ad--inside .kp-bb-ad__box [class*="related"],
.kp-notation-ad--inside .kp-bb-ad__box [id*="google"],
.kp-notation-ad--inside .kp-bb-ad__box iframe {
  max-width: 100% !important;
  box-sizing: border-box !important;
}
