/* OMI Pro V37 — desktop overlap and icon/text spacing fixes.
   Loaded after V36. Keep mobile shell and exam content unchanged. */
:root{
  --omi-desktop-nav-height:56px;
  --omi-desktop-chrome:calc(var(--omi-live-header,56px) + var(--omi-desktop-nav-height));
}

/* Prevent icon/shrinking-flex children from drawing across text in shared components. */
body.omi-layout :where(.menu-grid-new,.home-focus,.compact-links,.guidance-grid,.portal-primary,
  .portal-rows,.question-bank-layout,.omi-admin-grid,.omi-prompt-browser,.progress-summary,
  .system-tools,.settings-grid,.field-grid,.form-grid,.qbank-filter-row)>*{min-width:0}
body.omi-layout :where(.menu-grid-new a,.home-focus-card,.guidance-card,.portal-job,
  .portal-rows a,.question-list-item,.v29-bank-item,.option-edit-row,.settings-disclosure>summary,
  .backup-row,.omi-question-card,.omi-package-card)>:where(span,div,strong,small,label,b){min-width:0;overflow-wrap:anywhere}
body.omi-layout :where(.btn,.omi-btn,.primary-btn,.secondary-btn,.portal-inline-links a,
  .editor-actions button,.bank-bulk-toolbar button,.qeditor-toolbar button){min-width:0;max-width:100%;line-height:1.35;text-overflow:clip;overflow-wrap:anywhere}
body.omi-layout :where(.btn,.omi-btn,.primary-btn,.secondary-btn) :where(svg,.icon,.lucide){flex:0 0 auto;max-width:24px;max-height:24px}
body.omi-layout :where(.qeditor-head,.section-heading,.editor-actions,.omi-question-actions,
  .bank-bulk-toolbar,.qbank-prompt-toolbar,.omi-context-actions){min-width:0;column-gap:10px;row-gap:8px;flex-wrap:wrap}
body.omi-layout :where(.qeditor-head,.section-heading) :where(h1,h2,h3){min-width:0;max-width:100%;overflow-wrap:anywhere}

/* BUG: V33 overwrote 68px left padding while the V21 quick-link icon remained absolute.
   Make the icon an actual grid column, rather than place it over the label. */
body.omi-layout .compact-links a{
  display:grid!important;grid-template-columns:42px minmax(0,1fr) auto!important;
  grid-template-rows:auto!important;align-items:center!important;justify-content:stretch!important;
  gap:12px!important;min-width:0!important;min-height:82px!important;
  padding:12px 14px!important;text-align:left!important;overflow:hidden!important;
}
body.omi-layout .compact-links a::before{
  position:static!important;inset:auto!important;translate:none!important;transform:none!important;
  grid-column:1!important;grid-row:1!important;width:42px!important;height:42px!important;
  margin:0!important;flex:none!important;
}
body.omi-layout .compact-links a>span:first-of-type{
  grid-column:2!important;grid-row:1!important;min-width:0!important;
  display:grid!important;gap:3px!important;text-align:left!important;
}
body.omi-layout .compact-links a>span:last-of-type:not(:first-of-type){
  grid-column:3!important;grid-row:1!important;position:static!important;
  display:inline-flex!important;align-items:center!important;justify-content:center!important;
  min-width:18px!important;max-width:25px!important;flex:none!important;
}
body.omi-layout .compact-links strong,body.omi-layout .compact-links small{
  display:block!important;max-width:100%!important;line-height:1.35!important;
  white-space:normal!important;overflow-wrap:anywhere!important;
}

/* Menu cards: all three items get their own grid track, including the arrow. */
body.omi-layout .menu-grid-new a.v21-menu-card{
  display:grid!important;grid-template-columns:48px minmax(0,1fr) 20px!important;
  align-items:center!important;column-gap:12px!important;row-gap:6px!important;
  height:auto!important;min-height:86px!important;overflow:hidden!important;
}
body.omi-layout .v21-menu-card>.v21-menu-icon{grid-column:1;min-width:48px;max-width:48px;flex:0 0 48px}
body.omi-layout .v21-menu-card>span:nth-child(2){grid-column:2;min-width:0;display:grid;gap:3px}
body.omi-layout .v21-menu-card>.v21-menu-arrow{grid-column:3;min-width:0;justify-self:end;text-align:right}
body.omi-layout .v21-menu-card :where(strong,small){min-width:0;max-width:100%;white-space:normal;overflow-wrap:anywhere}
body.omi-layout .home-focus-card{grid-template-columns:48px minmax(0,1fr)!important;grid-template-rows:auto auto!important;align-content:center!important;row-gap:12px!important}
body.omi-layout .home-focus-card>.home-card-icon{grid-column:1;grid-row:1 / span 2;align-self:start;min-width:0}
body.omi-layout .home-focus-card>span:nth-child(2){grid-column:2;grid-row:1;min-width:0}
body.omi-layout .home-focus-card>b{grid-column:2;grid-row:2;min-width:0;max-width:100%;white-space:normal;line-height:1.3}
body.omi-layout :where(.home-intro-copy,.home-focus-card strong,.guidance-card h3,.portal-job strong){overflow-wrap:break-word}

/* Decorative halos are background artwork, never a foreground layer over copy. */
body.omi-layout :where(.portal-job,.progress-stat,.progress-overview-card,.portal-intro,
  .student-intro,.progress-intro,.guidance-card) :where(h1,h2,h3,p,b,strong,small,span){position:relative;z-index:1}
body.omi-layout :where(.portal-job,.progress-stat,.progress-overview-card,.portal-intro,
  .student-intro,.progress-intro,.guidance-card)::after{pointer-events:none;z-index:0}

/* Keep table content intact instead of clipping a long identifier or formula. */
body.omi-layout :where(.table-wrap,.table-scroll,.table-responsive,.responsive-table,.qbank-table-wrap){min-width:0;max-width:100%;overflow-x:auto;overscroll-behavior-x:contain}
body.omi-layout :where(.table-wrap,.table-scroll,.table-responsive,.responsive-table) table{width:100%;max-width:none}
body.omi-layout :where(.student-preview,.question-card,.cbt-question-card) :where(.option,.preview-option,.cbt-choice){min-width:0;overflow-wrap:break-word}
body.omi-layout :where(.student-preview,.question-card,.cbt-question-card) :where(.option-content,.preview-option-body,.cbt-choice-text){min-width:0;max-width:100%;overflow-wrap:break-word}

/* Desktop-only two-row application chrome (header + destinations) gets exactly one reserved area. */
@media (min-width:900px){
  body.omi-layout:not(.omi-native-android):not(.omi-exam-active):not(.omi-secure-exam){
    padding-top:calc(var(--omi-desktop-chrome) + 14px)!important;
    padding-bottom:32px!important;
  }
  body.omi-layout:not(.omi-native-android)>#omi-fixed-header{
    position:fixed!important;top:0!important;right:0!important;left:0!important;
    width:100%!important;height:var(--omi-live-header,56px)!important;
    min-height:var(--omi-live-header,56px)!important;max-width:100%!important;
    display:flex!important;align-items:center!important;justify-content:flex-start!important;
    gap:10px!important;padding:5px max(24px,calc((100vw - 1460px)/2))!important;
    z-index:1000!important;overflow:hidden!important;
  }
  body.omi-layout:not(.omi-native-android)>#omi-fixed-header .omi-back,
  body.omi-layout:not(.omi-native-android)>#omi-fixed-header .omi-brand-link,
  body.omi-layout:not(.omi-native-android)>#omi-fixed-header .omi-sound-toggle,
  body.omi-layout:not(.omi-native-android)>#omi-fixed-header .omi-menu-toggle{
    flex:0 0 40px!important;width:40px!important;height:40px!important;
    min-width:40px!important;min-height:40px!important;margin:0!important;
    display:flex!important;align-items:center!important;justify-content:center!important;
  }
  body.omi-layout:not(.omi-native-android)>#omi-fixed-header .omi-page-name{
    display:-webkit-box!important;-webkit-line-clamp:2;-webkit-box-orient:vertical;
    flex:1 1 auto!important;min-width:0!important;max-width:100%!important;
    white-space:normal!important;overflow:hidden!important;text-overflow:ellipsis!important;
    overflow-wrap:anywhere!important;line-height:1.3!important;font-size:14px!important;
  }
  body.omi-layout:not(.omi-native-android):not(.omi-exam-active):not(.omi-secure-exam)>.omi-primary-nav{
    position:fixed!important;left:0!important;right:0!important;
    top:var(--omi-live-header,56px)!important;bottom:auto!important;
    transform:none!important;margin:0!important;width:100%!important;
    height:var(--omi-desktop-nav-height)!important;min-height:var(--omi-desktop-nav-height)!important;
    max-width:none!important;display:grid!important;
    grid-template-columns:repeat(4,minmax(0,1fr))!important;
    gap:8px!important;padding:5px max(24px,calc((100vw - 900px)/2))!important;
    border-radius:0!important;border-top:0!important;border-bottom:1px solid #dfe9e5!important;
    background:#fff!important;box-shadow:0 5px 15px rgba(18,55,45,.055)!important;
    z-index:990!important;
  }
  body.omi-layout>.omi-primary-nav>a{
    display:flex!important;flex-direction:row!important;align-items:center!important;
    justify-content:center!important;min-width:0!important;min-height:44px!important;
    gap:10px!important;padding:4px 12px!important;
    font-size:13px!important;line-height:1.35!important;white-space:nowrap!important;
    overflow:hidden!important;text-overflow:ellipsis!important;
  }
  body.omi-layout>.omi-primary-nav>a>.omi-nav-glyph{
    flex:0 0 34px!important;width:34px!important;height:34px!important;
    min-width:34px!important;transform:none!important;
  }
  body.omi-layout>.omi-primary-nav>a>span:last-child{
    display:block!important;flex:0 1 auto!important;min-width:0!important;
    white-space:nowrap!important;overflow:hidden!important;text-overflow:ellipsis!important;
  }
  body.omi-layout .omi-context-actions{
    max-width:min(1240px,calc(100% - 36px))!important;
    margin:10px auto 0!important;padding:0!important;overflow:visible!important;
    align-items:center!important;justify-content:flex-end!important;
  }
  body.omi-layout :where(.omi-page-options .omi-options-panel){
    top:calc(var(--omi-desktop-chrome) + 8px)!important;
    max-height:calc(100dvh - var(--omi-desktop-chrome) - 22px)!important;
  }
  body.omi-layout .omi-admin .toolbar,body.omi-layout.omi-admin .toolbar,
  body.omi-layout.omi-monitor .toolbar,body.omi-layout.omi-catalog .toolbar{
    top:calc(var(--omi-desktop-chrome) + 10px)!important;
    scroll-margin-top:calc(var(--omi-desktop-chrome) + 12px)!important;
  }
  body.omi-layout .omi-package-panel,body.omi-layout .question-list-panel{
    top:calc(var(--omi-desktop-chrome) + 12px)!important;
    max-height:calc(100dvh - var(--omi-desktop-chrome) - 28px)!important;
  }
  body.omi-layout .omi-page-shell,body.omi-layout .omi-directory,
  body.omi-layout main.wrap,body.omi-layout main.guidance-main,
  body.omi-layout>.archive-main{
    margin-top:0!important;padding-top:clamp(14px,2.5vw,26px)!important;
  }
  body.omi-layout :where([id],.card,.panel,.qeditor-section,.portal-section,details){
    scroll-margin-top:calc(var(--omi-desktop-chrome) + 16px);
  }
  /* Make desktop exam/practice actions legible, not five indistinguishable glyphs. */
  body.legacy-app .q-nav{width:min(860px,calc(100% - 10px))!important}
  body.legacy-app .q-nav button{
    display:flex!important;align-items:center!important;justify-content:center!important;
    gap:9px!important;min-width:0!important;width:auto!important;
    height:auto!important;min-height:48px!important;padding:9px 12px!important;
    font-size:13px!important;line-height:1.3!important;white-space:normal!important;
  }
  body.legacy-app .q-nav button::before{flex:0 0 auto!important;font-size:20px!important}
  body.omi-exam-active .exam-actions,body.omi-secure-exam .exam-actions{
    width:min(880px,calc(100% - 12px))!important;
  }
  body.omi-exam-active .exam-actions .btn,body.omi-secure-exam .exam-actions .btn{
    display:flex!important;align-items:center!important;justify-content:center!important;
    gap:8px!important;min-width:0!important;width:auto!important;
    height:auto!important;min-height:48px!important;padding:9px 11px!important;
    font-size:12px!important;line-height:1.25!important;white-space:normal!important;
  }
  body.omi-exam-active .exam-actions .btn::before,
  body.omi-secure-exam .exam-actions .btn::before{flex:0 0 auto!important;font-size:20px!important}
  /* Icon badge in subject intro must not sit over the headline. */
  body.legacy-app #welcomeScreen .hero-main{min-width:0!important}
  body.legacy-app #welcomeScreen .hero-main::before{pointer-events:none!important}
  body.legacy-app #welcomeScreen .hero-main h2{
    position:relative;z-index:1;max-width:100%!important;min-width:0!important;
    padding-right:100px!important;overflow-wrap:break-word!important;
  }
}

@media (min-width:900px) and (max-width:1150px){
  body.omi-layout .compact-links{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  body.omi-layout .guidance-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  body.legacy-app #welcomeScreen .hero{grid-template-columns:minmax(0,1fr)!important}
}
@media (min-width:900px) and (max-width:1020px){
  body.omi-layout .omi-prompt-browser.omi-admin-grid.two{grid-template-columns:minmax(0,1fr)!important}
  body.omi-layout .question-bank-layout{grid-template-columns:minmax(230px,270px) minmax(0,1fr)!important}
  body.omi-layout .omi-menu-section>div{grid-template-columns:minmax(0,1fr)!important}
}
/* On smaller screens, do not undo the intentionally compact V36 mobile navigation. */
@media (max-width:899px){
  body.omi-layout .compact-links a{
    display:flex!important;flex-direction:column!important;align-items:center!important;
    justify-content:center!important;gap:5px!important;min-height:82px!important;
    padding:8px 5px!important;text-align:center!important;
  }
  body.omi-layout .compact-links a::before{position:static!important;width:35px!important;height:35px!important}
  body.omi-layout .compact-links a>span:first-of-type{
    display:block!important;text-align:center!important;min-width:0!important;
  }
  body.omi-layout .compact-links a>span:last-of-type:not(:first-of-type){display:none!important}
  body.omi-layout .compact-links small{display:none!important}
  body.omi-layout .compact-links strong{font-size:.75rem!important;line-height:1.17!important}
}
@media print{
  body.omi-layout>.omi-primary-nav,body.omi-layout>#omi-fixed-header{display:none!important}
  body.omi-layout{padding:0!important}
}

/* Standalone admin authentication pages use their own header, without the shared JS shell. */
@media (min-width:900px){
  body.omi-login,body.omi-auth-page{
    min-height:100dvh!important;padding-top:86px!important;
    padding-right:24px!important;padding-left:24px!important;
  }
  body.omi-login>#omi-fixed-header,body.omi-auth-page>#omi-fixed-header{
    position:fixed!important;inset:0 0 auto!important;height:64px!important;min-height:64px!important;
    display:flex!important;align-items:center!important;justify-content:space-between!important;
    padding:10px max(24px,calc((100vw - 1460px)/2))!important;
    gap:12px!important;z-index:1000!important;overflow:hidden!important;
  }
  body.omi-login>#omi-fixed-header>a,body.omi-auth-page>#omi-fixed-header>a{
    max-width:48%;min-width:0;white-space:normal;overflow-wrap:anywhere;text-align:center;
  }
  body.omi-login .login,body.omi-auth-page .v29-auth-card{
    width:min(500px,100%)!important;min-width:0!important;max-width:100%!important;
    margin:0 auto!important;
  }
  body.omi-login .brand{min-width:0;gap:12px}
  body.omi-login .brand>span:last-child{min-width:0;overflow-wrap:anywhere}
}

/* Desktop visual review: restore white lettering on colored home cards.
   Earlier generic card-heading rules unintentionally made it dark on a dark surface. */
body.omi-layout .home-focus-card.learn :where(small,strong,em),
body.omi-layout .home-focus-card.exam :where(small,strong,em){color:#fff!important}
body.omi-layout .home-focus-card :where(small,em){opacity:.90!important}

@media(min-width:1151px){
  body.omi-layout .compact-links{grid-template-columns:repeat(3,minmax(0,1fr))!important}
}
@media(min-width:900px){
  /* Menu descriptions were removed by an older mobile-density rule; show on desktop. */
  body.omi-layout .omi-menu-page .menu-grid-new a.v21-menu-card small{
    display:block!important;line-height:1.35!important;font-size:12px!important;
    color:#627487!important;white-space:normal!important;overflow-wrap:anywhere!important;
  }
}
