/* GIC Focus Mode Toolbar Inset v1 — staging, learner display only.
   Scope: contextual/extra layers (including the fourth layer).
   This deliberately does not style the lesson body, audio buttons or review rail. */

html body main.gic-final-study-page .gic-layer-panel[data-gic-contextual="1"] {
  box-sizing: border-box !important;
  min-width: 0 !important;
  max-width: 100% !important;
}

/* Keep both top controls inside an inset header, rather than letting the
   fourth layer's long title and the action row push them outside the card. */
html body main.gic-final-study-page .gic-layer-panel[data-gic-contextual="1"] .gic-layer-head {
  box-sizing: border-box !important;
  position: relative !important;
  inset: auto !important;
  transform: none !important;
  translate: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  flex-wrap: nowrap !important;
  column-gap: 10px !important;
  width: calc(100% - 20px) !important;
  min-width: 0 !important;
  max-width: calc(100% - 20px) !important;
  min-height: 50px !important;
  margin: 8px auto 12px !important;
  padding: 7px 11px !important;
  border: 1px solid #e1e8e4 !important;
  border-radius: 15px !important;
  background: #ffffff !important;
  box-shadow: 0 3px 12px rgba(27,49,39,.035) !important;
}

html body main.gic-final-study-page .gic-layer-panel[data-gic-contextual="1"] .gic-layer-title {
  box-sizing: border-box !important;
  flex: 1 1 0% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  margin: 0 !important;
}

html body main.gic-final-study-page .gic-layer-panel[data-gic-contextual="1"] .gic-layer-head-actions {
  box-sizing: border-box !important;
  position: relative !important;
  inset: auto !important;
  transform: none !important;
  translate: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  flex-wrap: nowrap !important;
  gap: 8px !important;
  flex: 0 0 auto !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

html body main.gic-final-study-page .gic-layer-panel[data-gic-contextual="1"] :is(.gic-layer-focus, .gic-layer-close) {
  box-sizing: border-box !important;
  position: relative !important;
  inset: auto !important;
  transform: none !important;
  translate: none !important;
  margin: 0 !important;
  white-space: nowrap !important;
  max-width: 100% !important;
}

html body main.gic-final-study-page .gic-layer-panel[data-gic-contextual="1"] .gic-layer-focus {
  flex: 0 1 auto !important;
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

html body main.gic-final-study-page .gic-layer-panel[data-gic-contextual="1"] .gic-layer-close {
  flex: 0 0 36px !important;
  width: 36px !important;
  min-width: 36px !important;
  max-width: 36px !important;
  height: 36px !important;
  min-height: 36px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* At phone widths, the contextual label gets its own row. Actions then
   stretch across the card, with Focus Mode on the left and × on the right. */
@media (max-width: 440px) {
  html body main.gic-final-study-page .gic-layer-panel[data-gic-contextual="1"] .gic-layer-head {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    row-gap: 7px !important;
    width: calc(100% - 16px) !important;
    max-width: calc(100% - 16px) !important;
    min-height: 0 !important;
    margin: 7px auto 10px !important;
    padding: 9px 11px !important;
  }
  html body main.gic-final-study-page .gic-layer-panel[data-gic-contextual="1"] .gic-layer-title {
    flex: 0 1 auto !important;
    align-self: flex-start !important;
    max-width: 100% !important;
  }
  html body main.gic-final-study-page .gic-layer-panel[data-gic-contextual="1"] .gic-layer-head-actions {
    flex: 0 0 auto !important;
    display: flex !important;
    align-self: stretch !important;
    justify-content: space-between !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  html body main.gic-final-study-page .gic-layer-panel[data-gic-contextual="1"] .gic-layer-focus {
    max-width: calc(100% - 44px) !important;
  }
}
