/* Math Studio dark mode repair */
.math-studio-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:8px}.math-studio-head h3{margin:0}.math-studio-close{width:34px;height:34px;border-radius:999px;border:1px solid rgba(148,163,184,.42);background:rgba(255,255,255,.92);color:#0f172a;font-size:1.25rem;font-weight:900;line-height:1;cursor:pointer;display:inline-grid;place-items:center;flex:0 0 auto}body.ui-dark-mode .math-studio-panel .math-studio-head h3,body.ui-dark-mode .math-studio-panel b{color:#eef6ff}body.ui-dark-mode .math-studio-panel p{color:#aebbd0}body.ui-dark-mode .math-studio-close{background:rgba(15,23,42,.9);color:#f8fafc;border-color:rgba(226,232,240,.34)}body.ui-dark-mode .geometry-lab,body.ui-dark-mode .math-studio-panel .geometry-lab{background:linear-gradient(180deg,rgba(15,23,42,.96),rgba(10,18,32,.98))!important;border-color:rgba(125,211,252,.34)!important;box-shadow:inset 0 0 0 1px rgba(255,255,255,.035),0 14px 34px rgba(0,0,0,.32)!important}body.ui-dark-mode .geometry-toolbar,body.ui-dark-mode .math-studio-panel .geometry-toolbar{background:transparent!important;color:#e0f2fe!important}body.ui-dark-mode .geo-btn,body.ui-dark-mode .math-studio-panel .geo-btn{background:rgba(15,23,42,.78)!important;color:#dff7ff!important;border-color:rgba(125,211,252,.46)!important;opacity:1!important}body.ui-dark-mode .geo-btn.active,body.ui-dark-mode .math-studio-panel .geo-btn.active,body.ui-dark-mode .math-studio-panel .rational-btn{background:linear-gradient(135deg,rgba(14,165,233,.24),rgba(124,58,237,.18))!important;color:#f0fbff!important;border-color:rgba(103,232,249,.62)!important}body.ui-dark-mode .geometry-card,body.ui-dark-mode .math-studio-panel .geometry-card{background:rgba(8,13,24,.98)!important;border-color:rgba(125,211,252,.26)!important}body.ui-dark-mode .geometry-sketch,body.ui-dark-mode .math-studio-panel .geometry-sketch,body.ui-dark-mode .geo-notebook,body.ui-dark-mode .math-studio-panel .geo-notebook,body.ui-dark-mode .math-studio-input.notebook-typing{background:repeating-linear-gradient(180deg,rgba(125,211,252,.12),rgba(125,211,252,.12) 1px,transparent 1px,transparent 34px),#f8fbff!important;color:#0f172a!important;border-color:rgba(125,211,252,.46)!important}body.ui-dark-mode .geometry-actions,body.ui-dark-mode .math-studio-panel .geometry-actions{background:rgba(8,13,24,.98)!important}body.ui-dark-mode #solveGeometryBtn,body.ui-dark-mode .math-studio-panel #solveGeometryBtn{background:linear-gradient(180deg,#bae6fd,#7dd3fc)!important;color:#083344!important;border-color:rgba(186,230,253,.86)!important}body.ui-dark-mode .math-studio-output{background:rgba(15,23,42,.76)!important;color:#eef6ff!important;border-color:rgba(148,163,184,.28)!important}
/* Dark math footer/safety strip repair */
body.ui-dark-mode .app.math-mode .composer-safety-info {
  background: rgba(7, 11, 22, .86) !important;
  border: 1px solid rgba(125, 211, 252, .16) !important;
  border-radius: 999px !important;
  box-shadow: 0 -8px 22px rgba(0,0,0,.18) !important;
  backdrop-filter: blur(8px);
  padding: 2px 8px !important;
}
body.ui-dark-mode .app.math-mode .composer-safety-info summary,
body.ui-dark-mode .app.math-mode .composer-safety-info summary > span:first-child {
  color: #cbd5e1 !important;
}
body.ui-dark-mode .app.math-mode .account-disclosure-arrow::before {
  color: #94a3b8 !important;
}
body.ui-dark-mode .app.math-mode .context-usage-summary.math-context {
  color: #bae6fd !important;
  background: rgba(14, 165, 233, .18) !important;
  box-shadow: inset 0 0 0 1px rgba(125, 211, 252, .25) !important;
}
body.ui-dark-mode .app.math-mode .context-usage-summary.math-context .context-usage-ring i {
  background: #082f49 !important;
}
body.ui-dark-mode .app.math-mode .composer-safety-info[open] .account-safety-details {
  background: rgba(10, 14, 25, .96) !important;
  color: #e2e8f0 !important;
  border: 1px solid rgba(148, 163, 184, .24) !important;
}
@media (max-width: 720px) {
  body.ui-dark-mode .app.math-mode .composer-safety-info {
    width: calc(100% - 28px) !important;
    border-radius: 12px !important;
  }
}

/* Dark math final polish: full footer band + visible menu button */
body.ui-dark-mode .app.math-mode .composer-safety-info {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 4px 10px 5px !important;
  border-radius: 0 !important;
  border: 0 !important;
  border-top: 1px solid rgba(148, 163, 184, .22) !important;
  background: linear-gradient(180deg, rgba(13, 18, 31, .98), rgba(7, 11, 22, .98)) !important;
  box-shadow: 0 -10px 24px rgba(0,0,0,.22) !important;
}
body.ui-dark-mode .app.math-mode .composer-safety-info summary {
  min-height: 18px !important;
}
body.ui-dark-mode .app.math-mode .composer-safety-info summary > span:first-child {
  color: #d5deec !important;
  text-shadow: none !important;
}
body.ui-dark-mode .app.math-mode #accountToggle,
body.ui-dark-mode .app.math-mode .account-icon-btn {
  background: rgba(15, 23, 42, .92) !important;
  color: #f8fafc !important;
  border-color: rgba(226, 232, 240, .38) !important;
  box-shadow: 0 0 0 1px rgba(255,255,255,.04), 0 0 14px rgba(56,189,248,.22) !important;
}
body.ui-dark-mode .app.math-mode #accountToggle svg,
body.ui-dark-mode .app.math-mode #accountToggle .account-toggle-avatar,
body.ui-dark-mode .app.math-mode #accountToggle .account-toggle-menu {
  color: #f8fafc !important;
  opacity: 1 !important;
  filter: none !important;
}
body.ui-dark-mode .app.math-mode #accountToggle path,
body.ui-dark-mode .app.math-mode #accountToggle circle {
  stroke: currentColor !important;
}
@media (max-width: 720px) {
  body.ui-dark-mode .app.math-mode .composer-safety-info {
    width: 100% !important;
    border-radius: 0 !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
  }
}

body.ui-dark-mode .thinking-head,
body.ui-dark-mode .thinking-head span {
  color: #f8fafc !important;
}

/* Keep every exposed Math surface dark. The composer is intentionally
   transparent, so it must inherit a dark Math canvas instead of the
   light-mode blue gradient. */
body.ui-dark-mode .app.math-mode {
  background:
    radial-gradient(circle at 50% 0%, rgba(14, 116, 144, .12), transparent 42%),
    #111722 !important;
  color: #eef6ff;
}
body.ui-dark-mode .app.math-mode .input-shell,
body.ui-dark-mode .app.math-mode .math-ask-guide {
  background: transparent !important;
}
body.ui-dark-mode .app.math-mode .math-ask-guide summary,
body.ui-dark-mode .app.math-mode .math-ask-guide-panel {
  color: #dff7ff !important;
  background: rgba(8, 47, 73, .94) !important;
  border-color: rgba(56, 189, 248, .38) !important;
}
body.ui-dark-mode .app.math-mode .math-ask-guide-panel code {
  color: #e0f2fe !important;
  background: rgba(14, 116, 144, .42) !important;
}

/* Math teacher: dark card, readable copy and coherent blue controls. */
body.ui-dark-mode .math-tutor-bubble {
  color: #eef6ff !important;
  background: linear-gradient(160deg, rgba(15, 23, 42, .98), rgba(8, 47, 73, .96)) !important;
  border-color: rgba(125, 211, 252, .42) !important;
  box-shadow: 0 18px 46px rgba(0, 0, 0, .46), 0 0 24px rgba(14, 165, 233, .12) !important;
}
body.ui-dark-mode .math-tutor-bubble strong,
body.ui-dark-mode .math-tutor-bubble p,
body.ui-dark-mode .math-tutor-bubble b {
  color: #f8fafc !important;
}
body.ui-dark-mode .math-tutor-bubble p {
  color: #cbd5e1 !important;
}
body.ui-dark-mode .math-tutor-bubble button {
  color: #e0f2fe !important;
  background: rgba(14, 116, 144, .32) !important;
  border-color: rgba(125, 211, 252, .52) !important;
}
body.ui-dark-mode .math-tutor-bubble button:hover {
  background: rgba(14, 165, 233, .42) !important;
}
