/* October 8–9 visual audit: scoped layout repairs, loaded after legacy themes. */
/* Game reveal controls use the native hidden attribute. Legacy grid/flex rules
   must not expose choices early or retain the flash card after revealing them. */
.game-shell [hidden] { display:none!important; }
.game-shell .flash-card {
  min-height:0!important;
  height:auto!important;
  align-content:start!important;
  padding:16px!important;
}
.study-plan-dialog {
  position:fixed!important;
  inset:12px!important;
  transform:none!important;
  box-sizing:border-box!important;
  width:min(100% - 24px,960px)!important;
  height:auto!important;
  max-height:calc(100dvh - 24px)!important;
  max-width:960px!important;
  margin:auto!important;
  padding:0!important;
  overflow:auto!important;
  border-radius:18px!important;
  overscroll-behavior:contain;
}
.study-plan-dialog #studyPlanForm {
  display:flex!important;
  flex-direction:column!important;
  gap:18px!important;
  width:100%!important;
  height:auto!important;
  min-height:0!important;
  padding:22px!important;
  overflow:visible!important;
}
.study-plan-dialog #studyPlanForm > * {
  position:static!important;
  flex-shrink:0!important;
  min-width:0!important;
  max-width:100%!important;
}
.study-plan-dialog #studyPlanForm fieldset {
  box-sizing:border-box!important;
  min-inline-size:0!important;
  width:100%!important;
  height:auto!important;
  margin:0!important;
  padding:14px!important;
  overflow:visible!important;
}
.study-plan-dialog #studyPlanForm label {
  margin:0!important;
  min-width:0!important;
  height:auto!important;
  align-content:start!important;
  line-height:1.4!important;
}
.study-plan-dialog #studyPlanForm .plan-form-grid {
  display:grid!important;
  grid-template-columns:repeat(3,minmax(0,1fr))!important;
  gap:14px!important;
}
.study-plan-dialog #studyPlanForm .plan-accommodation-fields {
  display:grid!important;
  grid-template-columns:repeat(2,minmax(0,1fr))!important;
  gap:14px!important;
}
.study-plan-dialog #studyPlanForm [hidden] { display:none!important; }
.study-plan-dialog #studyPlanForm .plan-accommodation-toggle {
  display:grid!important;
  grid-template-columns:20px minmax(0,1fr)!important;
  gap:10px!important;
  align-items:start!important;
  width:100%!important;
}
.study-plan-dialog #studyPlanForm input:is([type=checkbox],[type=radio]) {
  display:block!important;
  box-sizing:border-box!important;
  width:20px!important;
  min-width:20px!important;
  max-width:20px!important;
  height:20px!important;
  min-height:20px!important;
  max-height:20px!important;
  padding:0!important;
  margin:2px 0 0!important;
  flex:none!important;
  accent-color:#a94f24;
}
.study-plan-dialog #studyPlanForm .plan-track-options label {
  grid-template-columns:20px minmax(0,1fr)!important;
  padding:12px!important;
}
.study-plan-dialog #studyPlanForm .actions {
  position:static!important;
  display:grid!important;
  grid-template-columns:1fr 1fr!important;
  gap:12px!important;
  margin:0!important;
  padding:0!important;
}
.study-plan-dialog #studyPlanForm :is(.muted,small,.plan-dialog-preview span) { line-height:1.45!important; }
html.jg-theme-light body:not(.high-contrast) .study-plan-dialog,
html.jg-theme-light body:not(.high-contrast) .study-plan-dialog #studyPlanForm {
  background:#fffaf6!important;
  background-image:none!important;
  color:#211f1d!important;
  -webkit-text-fill-color:#211f1d!important;
}
html.jg-theme-light body:not(.high-contrast) .study-plan-dialog #studyPlanForm :is(label,legend,h2,strong,span) {
  color:#211f1d!important;
  -webkit-text-fill-color:#211f1d!important;
}
html.jg-theme-light body:not(.high-contrast) .study-plan-dialog #studyPlanForm :is(.muted,small,.eyebrow,.plan-track-confirm) {
  color:#665347!important;
  -webkit-text-fill-color:#665347!important;
}
html.jg-theme-light body:not(.high-contrast) .study-plan-dialog #studyPlanForm :is(fieldset,.plan-dialog-preview) {
  background:#f4eee8!important;
  background-image:none!important;
  border:1px solid #cbbbad!important;
}
html.jg-theme-light body:not(.high-contrast) .study-plan-dialog #studyPlanForm .plan-dialog-head {
  background:#fffaf6!important;
  background-image:none!important;
}
.study-plan-dialog #studyPlanForm :is(input:not([type=checkbox]):not([type=radio]),select) {
  /* These fields use a light surface in both existing themes. */
  color-scheme:light;
}
html.jg-theme-light body:not(.high-contrast) .study-plan-dialog #studyPlanForm :is(input:not([type=checkbox]):not([type=radio]),select) {
  background:#fff!important;
  color:#211f1d!important;
  -webkit-text-fill-color:#211f1d!important;
  border-color:#b7a89b!important;
}
html.jg-theme-light body:not(.high-contrast) .study-plan-dialog #studyPlanForm :is(input,select,button):focus-visible {
  outline:2px solid #a94f24!important;
  outline-offset:3px!important;
}
html.jg-theme-light body:not(.high-contrast) .study-plan-dialog #studyPlanForm .btn-primary {
  background:#a94f24!important;
  color:#fff!important;
  -webkit-text-fill-color:#fff!important;
}
body.jg-landing-active .jg-public-nav nav [data-jg-login-open] {
  display:inline-flex!important;
  align-items:center!important;
  justify-content:center!important;
  min-height:42px!important;
  padding:10px 20px!important;
  border:0!important;
  border-radius:10px!important;
  line-height:1.2!important;
}
body.game-mode-active #app .mechanic-crossroads .purpose-options button {
  box-sizing:border-box!important;
  /* Keep the crossroads arrow silhouette; inset text beyond both notches. */
  padding:12px max(32px,10%)!important;
  height:auto!important;
  min-height:54px!important;
  white-space:normal!important;
  overflow-wrap:anywhere!important;
}
body:not(.mock-mode-active) #app.mock-control-active {
  box-sizing:border-box!important;
  height:auto!important;
  min-height:0!important;
  /* Give the chooser its own scroll lane ending above the fixed dock. */
  max-height:calc(100dvh - 200px - env(safe-area-inset-bottom))!important;
  padding-bottom:24px!important;
  overflow-y:auto!important;
  overflow-x:hidden!important;
  overscroll-behavior:contain;
}
html.jg-theme-light body:not(.high-contrast) #app .mock-direct-grid button.selected :is(.badge,small),
html.jg-theme-light body:not(.high-contrast) #app .mock-direct-grid button.selected::after {
  background:#eee1d6!important;
  color:#743d24!important;
  -webkit-text-fill-color:#743d24!important;
}
html.jg-theme-light body:not(.high-contrast) #app .track-control button.selected::after {
  background:#eee1d6!important;
  color:#743d24!important;
  -webkit-text-fill-color:#743d24!important;
}
html.jg-theme-light body:not(.high-contrast) #app .reasoning-step summary b {
  background:#eee1d6!important;
  color:#743d24!important;
  -webkit-text-fill-color:#743d24!important;
  border-color:#cbbbad!important;
}
@media(max-width:700px) {
  .study-plan-dialog #studyPlanForm {padding:16px!important;gap:16px!important;}
  .study-plan-dialog #studyPlanForm .plan-form-grid,
  .study-plan-dialog #studyPlanForm .plan-accommodation-fields,
  .study-plan-dialog #studyPlanForm .plan-track-options {grid-template-columns:minmax(0,1fr)!important;}
  .study-plan-dialog #studyPlanForm .plan-accommodation-notes {grid-column:auto!important;}
  .study-plan-dialog #studyPlanForm .actions {grid-template-columns:1fr!important;}
}

@media screen {
/* 2026-10-11: a saved attempt adds a fourth dashboard row. Keep that row
   in normal flow so a tile cannot cover Resume/Discard after a reload. */
html body.dashboard-active:not(.jg-landing-active):not(.mock-mode-active):has(#app > .jg-saved-attempt-card) {
  height:auto!important;
  min-height:100dvh!important;
  max-height:none!important;
  overflow-y:auto!important;
}
html body.dashboard-active:not(.jg-landing-active):not(.mock-mode-active) #app:has(> .jg-saved-attempt-card) {
  position:relative!important;
  inset:auto!important;
  display:grid!important;
  grid-template-columns:minmax(0,1fr)!important;
  grid-template-rows:auto auto auto auto!important;
  height:auto!important;
  min-height:0!important;
  max-height:none!important;
  overflow:visible!important;
  align-content:start!important;
  gap:12px!important;
  padding-bottom:calc(84px + env(safe-area-inset-bottom))!important;
}
html body.dashboard-active:not(.jg-landing-active):not(.mock-mode-active) #app:has(> .jg-saved-attempt-card) > .dashboard-welcome {
  grid-column:1!important;
  grid-row:1!important;
}
html body.dashboard-active:not(.jg-landing-active):not(.mock-mode-active) #app:has(> .jg-saved-attempt-card) > .dashboard-track-switch {
  grid-column:1!important;
  grid-row:2!important;
}
html body.dashboard-active:not(.jg-landing-active):not(.mock-mode-active) #app > .jg-saved-attempt-card {
  position:relative!important;
  grid-column:1/-1!important;
  grid-row:3!important;
  min-width:0!important;
  height:auto!important;
  min-height:min-content!important;
  margin:0!important;
  overflow:visible!important;
}
html body.dashboard-active:not(.jg-landing-active):not(.mock-mode-active) #app:has(> .jg-saved-attempt-card) > .home-tile-hub.approved-home-grid.jg-v568-grid {
  position:relative!important;
  inset:auto!important;
  grid-column:1!important;
  grid-row:4!important;
  height:auto!important;
  min-height:0!important;
  max-height:none!important;
  margin:0!important;
  overflow:visible!important;
}
@media (min-width:901px) {
  html body.dashboard-active:not(.jg-landing-active):not(.mock-mode-active) #app:has(> .jg-saved-attempt-card) > .home-tile-hub.approved-home-grid.jg-v568-grid {
    grid-template-columns:repeat(4,minmax(0,1fr))!important;
    grid-template-rows:repeat(2,minmax(190px,auto))!important;
  }
}
@media (max-width:900px) {
  html body.dashboard-active:not(.jg-landing-active):not(.mock-mode-active) #app:has(> .jg-saved-attempt-card) > .home-tile-hub.approved-home-grid.jg-v568-grid {
    grid-template-rows:none!important;
    grid-auto-rows:minmax(82px,auto)!important;
  }
}
}

/* 2026-10-11: preserve single tile labels and readable curriculum copy in desktop high contrast. */
@media screen and (min-width:901px) {
  body.dashboard-active.high-contrast:not(.jg-landing-active):not(.mock-mode-active) #app .home-tile strong::after {
    content:none!important;
  }
  body.dashboard-active.high-contrast:not(.jg-landing-active):not(.mock-mode-active) #app .dashboard-track-switch > div:first-child :is(.dashboard-track-status,strong,small) {
    color:var(--text)!important;
    -webkit-text-fill-color:currentColor!important;
  }
}

/* Mock review and scheduled break belong to the existing plain exam surface.
   Keep the explicit accessibility palette, all non-exam art, and print intact. */
@media screen {
  body.mock-mode-active:not(.high-contrast) .submit-review.mock-review-shell {
    background:#fff;
    border-color:#aaa;
    box-shadow:none;
  }
  body.mock-mode-active:not(.high-contrast) .submit-review.mock-review-shell .stat {
    background:#f1f1f1;
    border-color:#aaa;
  }
  body.mock-mode-active:not(.high-contrast) .submit-review.mock-review-shell :is(h2,.stat b) {
    color:#111!important;
  }
  body.mock-mode-active:not(.high-contrast) .submit-review.mock-review-shell :is(.muted,.stat span) {
    color:#555!important;
  }
  body.mock-mode-active:not(.high-contrast) .submit-review.mock-review-shell .eyebrow,
  body.mock-mode-active:not(.high-contrast) .exam-card:has(#breakClock) > .eyebrow {
    color:#444;
  }
  body.mock-mode-active:not(.high-contrast) .submit-review.mock-review-shell .btn-primary {
    background:#174d8c;
    color:#fff;
    box-shadow:none;
  }
  body.mock-mode-active:not(.high-contrast) .submit-review.mock-review-shell .btn-secondary {
    background:#f7f7f7;
    border-color:#aaa;
    color:#111!important;
  }
  body.mock-mode-active:not(.high-contrast) .exam-card .result-ring:has(> #breakClock) {
    background:conic-gradient(#174d8c var(--pct),#ddd 0);
  }
  body.mock-mode-active:not(.high-contrast) .exam-card .ring-inner#breakClock {
    background:#fff;
    color:#111;
  }
}

/* Confirmed high-contrast break: retain its black center and white exam card. */
@media screen {
  body.mock-mode-active.high-contrast .exam-card .ring-inner#breakClock {
    color:#fff;
  }
  body.mock-mode-active.high-contrast .exam-card:has(#breakClock) > :is(.eyebrow,.lead,.muted) {
    color:#111;
  }
}

/* Ordinary dark desktop Dashboard: show each original tile label once and
   keep curriculum text readable on its existing transparent/navy surface. */
@media screen and (min-width:901px) {
  html.jg-theme-dark body.dashboard-active:not(.high-contrast):not(.jg-landing-active):not(.mock-mode-active) #app .home-tile strong::after {
    content:none!important;
  }
  html.jg-theme-dark body.dashboard-active:not(.high-contrast):not(.jg-landing-active):not(.mock-mode-active) #app .dashboard-track-switch > div:first-child :is(.dashboard-track-status,strong,small) {
    color:var(--text)!important;
    -webkit-text-fill-color:currentColor!important;
  }
}
