/* V5.6.0 — unified subject shell and clear visual identity */
:root{
  --shell-radius:18px;
  --shell-shadow:0 8px 24px rgba(21,45,52,.09);
}
html{scroll-behavior:auto!important}
body{background-image:none!important}
body.subject-safety{
  --subject-main:#8f302d;
  --subject-main-2:#b64b35;
  --subject-accent:#e29a38;
  --subject-soft:#fff3e8;
  --subject-line:#ead2c8;
  background:linear-gradient(180deg,#fff4ea 0,#f7f1ed 42%,#fbfcfc 100%)!important;
}
body.subject-theory{
  --subject-main:#155e6c;
  --subject-main-2:#287a89;
  --subject-accent:#e8a22b;
  --subject-soft:#eaf6f8;
  --subject-line:#cce1e5;
  background:linear-gradient(180deg,#e9f6f8 0,#f1f7f8 42%,#fbfcfc 100%)!important;
}
body.subject-safety::before{background:radial-gradient(circle at 85% 0,rgba(226,154,56,.15),transparent 34%)!important}
body.subject-theory::before{content:"";position:fixed;inset:0;pointer-events:none;background:radial-gradient(circle at 85% 0,rgba(40,122,137,.14),transparent 35%);z-index:0}
body.ui-ready #studyDashboard,
body.ui-ready #dashboard{visibility:visible}
body:not(.ui-ready) #studyDashboard,
body:not(.ui-ready) #dashboard{visibility:hidden}

/* One visual language for both headers. */
body.subject-safety header,
body.subject-theory .app-header{
  border-radius:var(--shell-radius)!important;
  box-shadow:var(--shell-shadow)!important;
  border:1px solid color-mix(in srgb,var(--subject-line) 75%,transparent)!important;
}
body.subject-safety header{
  background:rgba(255,255,255,.93)!important;
  color:var(--ink)!important;
  padding:10px 12px!important;
}
body.subject-safety header::before,
body.subject-safety header::after{display:none!important}
body.subject-safety header p{color:var(--muted)!important}
body.subject-safety .icon-btn{
  border-color:var(--subject-line)!important;
  background:#fff!important;
  color:var(--subject-main)!important;
  border-radius:11px!important;
}
body.subject-safety .header-icon{background:linear-gradient(145deg,#ffe3a1,#eaa63b)!important;border-radius:13px!important}
body.subject-theory .app-header{background:rgba(255,255,255,.93)!important}
body.subject-theory .brand-icon{background:linear-gradient(145deg,#bce8ef,#4ba0ae)!important}
body.subject-theory .brand-icon{color:#0e4a55}

/* Question cards match in spacing and hierarchy. */
body.subject-safety .stage,
body.subject-theory .quiz-card{
  border-radius:var(--shell-radius)!important;
  border:1px solid var(--subject-line)!important;
  box-shadow:var(--shell-shadow)!important;
  background:rgba(255,255,255,.96)!important;
  animation:none!important;
}
body.subject-safety .stage::before,
body.subject-theory .quiz-card::before{
  background:linear-gradient(90deg,var(--subject-main),var(--subject-accent))!important;
}
body.subject-safety .btn-next,
body.subject-theory .nav-btn.primary{background:var(--subject-main)!important;border-color:var(--subject-main)!important}
body.subject-safety .topic-badge,
body.subject-safety .badge,
body.subject-theory .question-meta span:first-child,
body.subject-theory .pill{color:var(--subject-main)!important;border-color:var(--subject-line)!important;background:var(--subject-soft)!important}
body.subject-safety .opt .letter,
body.subject-theory .option .letter{color:var(--subject-main)!important;border-color:color-mix(in srgb,var(--subject-main) 45%,white)!important;background:var(--subject-soft)!important}

/* Dashboards live in menus only. */
.menu-summary-title{
  margin:4px 0 8px;
  padding:0 2px;
  font-size:.9rem;
  font-weight:900;
  color:var(--subject-main);
}
.bottom-sheet #studyDashboard,
.drawer #dashboard{
  display:grid!important;
  grid-template-columns:1fr 1fr!important;
  gap:8px!important;
  margin:0 0 14px!important;
  width:100%!important;
}
.bottom-sheet #studyDashboard .dash-card,
.drawer #dashboard .stat-card{
  min-height:74px!important;
  padding:9px 7px!important;
  border-radius:14px!important;
  border:1px solid var(--subject-line)!important;
  background:linear-gradient(180deg,#fff,var(--subject-soft))!important;
  box-shadow:none!important;
  color:inherit!important;
}
.bottom-sheet #studyDashboard .dash-value,
.drawer #dashboard .stat-card b{
  font-size:1.08rem!important;
  color:var(--subject-main)!important;
}
.bottom-sheet #studyDashboard .dash-label,
.drawer #dashboard .stat-card span{font-size:.7rem!important;color:var(--muted)!important}

/* Shared drawer language. */
body.subject-safety .bottom-sheet,
body.subject-theory .drawer{
  background:rgba(255,255,255,.985)!important;
  width:min(88vw,390px)!important;
  box-shadow:-18px 0 44px rgba(0,0,0,.18)!important;
}
body.subject-safety .site-menu-head,
body.subject-theory .drawer-head{
  color:var(--text,var(--ink));
  border-bottom:1px solid var(--subject-line)!important;
}
body.subject-safety .site-menu-head button,
body.subject-theory .drawer-head button{
  background:var(--subject-soft)!important;
  color:var(--subject-main)!important;
}
body.subject-safety .sheet-grid,
body.subject-theory .drawer-grid{grid-template-columns:1fr 1fr!important;gap:9px!important}
body.subject-safety .sheet-btn,
body.subject-theory .drawer-grid button,
body.subject-theory .drawer-grid a{
  min-height:84px!important;
  border-radius:15px!important;
  border:1px solid var(--subject-line)!important;
  background:linear-gradient(180deg,#fff,#fafcfc)!important;
  color:var(--text,var(--ink))!important;
  box-shadow:none!important;
  font-size:.84rem!important;
  font-weight:800!important;
}
body.subject-safety .sheet-btn.accent,
body.subject-theory .drawer-grid .primary-menu-item{
  background:linear-gradient(145deg,var(--subject-main),var(--subject-main-2))!important;
  color:#fff!important;
  border-color:transparent!important;
}
body.subject-safety .sheet-btn.warn,
body.subject-theory .drawer-grid .danger-menu-item{
  background:#fff2f1!important;
  color:#9f302f!important;
  border-color:#efc5c2!important;
}
body.subject-theory .drawer-section-title,
body.subject-safety .sheet-group-title{
  grid-column:1/-1;
  text-align:right;
  font-weight:900;
  color:var(--subject-main)!important;
  font-size:.88rem!important;
  border-bottom:1px solid var(--subject-line)!important;
  padding:12px 2px 6px!important;
}
body.subject-theory .drawer-section-title:first-child{padding-top:0!important}

/* Safety search opens only when requested, keeping the menu calm. */
body.subject-safety .safety-search-section{display:none!important;margin:0 0 12px!important}
body.subject-safety .safety-search-section.search-open{display:block!important}
body.subject-safety .safety-filter-section{margin-top:12px!important;padding-top:12px!important;border-top:1px solid var(--subject-line)!important}

/* Main pages stay focused on studying. */
body.subject-safety #app > #studyDashboard,
body.subject-theory #app > #dashboard{display:none!important}
body.subject-safety .swipe-hint{display:none!important}
body.subject-theory footer,
body.subject-safety footer.note{opacity:.78}

/* Dark mode retains a subject tint. */
html.dark body.subject-safety,
body.subject-theory.dark{background:#1f1717!important}
html.dark body.subject-safety .bottom-sheet,
body.subject-theory.dark .drawer{background:#241d1d!important}
body.subject-theory.dark{--subject-soft:#1c3940;--subject-line:#34545b}
html.dark body.subject-safety{--subject-soft:#352422;--subject-line:#5b3a36}

@media(max-width:620px){
  body.subject-safety #app,
  body.subject-theory #app{padding-left:7px!important;padding-right:7px!important}
  .bottom-sheet #studyDashboard,
  .drawer #dashboard{gap:7px!important}
  .bottom-sheet #studyDashboard .dash-card,
  .drawer #dashboard .stat-card{min-height:70px!important}
}


/* V5.6.0 performance and stability refinements */
body.subject-safety .bottom-sheet,
body.subject-theory .drawer,
body.subject-safety .sheet-backdrop,
body.subject-theory .overlay{
  -webkit-backdrop-filter:none!important;
  backdrop-filter:none!important;
}
body.subject-safety .stage,
body.subject-theory .quiz-card,
body.subject-safety .opt,
body.subject-theory .option{
  contain:layout paint;
}
body.subject-safety .feedback-box,
body.subject-theory .feedback{overflow-anchor:none}
body.subject-safety .source-note-img{content-visibility:auto;contain-intrinsic-size:180px 320px}
body.subject-safety .bottom-sheet,
body.subject-theory .drawer{will-change:transform}
body.subject-safety .daily-goal-strip{display:none!important}
@media(prefers-reduced-motion:reduce){
  body.subject-safety *,body.subject-theory *{scroll-behavior:auto!important;animation:none!important;transition:none!important}
}

/* V5.6.0 — keep the question screen focused and consistent */
body.subject-safety #masteryBadge,body.subject-safety .swipe-hint{display:none!important}
body.subject-safety .menu-note-title{margin-top:16px!important}
body.subject-safety .menu-note-editor{display:block!important;margin:6px 0 2px;padding:10px;border:1px solid var(--shell-line);border-radius:14px;background:var(--shell-card)}
body.subject-safety .menu-note-editor .note-textarea{min-height:84px;resize:vertical}
body.subject-safety #topicRow{margin-bottom:7px}

/* V5.6.0 stability refinements */
body:not(.ui-ready).subject-safety #quizStage .note-editor{visibility:hidden}
body.ui-ready.subject-safety .menu-note-editor{visibility:visible}
body.subject-theory .index-grid,body.subject-theory .result-list,body.subject-safety .index-grid,body.subject-safety .search-results{contain:layout paint;content-visibility:auto;contain-intrinsic-size:600px}
body.subject-theory .question-visual{contain:layout paint;overflow-anchor:none}
