/* Modo noturno global do EstudaMath. Carregado depois dos estilos de cada módulo. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --navy: #eef4ff;
  --text: #e9f0ff;
  --muted: #aebbd1;
  --blue: #66adff;
  --blue-strong: #85bdff;
  --blue-soft: #142a46;
  --surface: #111d31;
  --surface-2: #17263d;
  --line: #2c405f;
  --shadow: 0 22px 54px rgba(0, 0, 0, .3);
}

html[data-theme="dark"],
html[data-theme="dark"] body,
html[data-theme="dark"] body.content-page,
html[data-theme="dark"] body.lesson-studio-page {
  background: #08111f !important;
  color: #e9f0ff;
}

html[data-theme="dark"] body::before {
  opacity: .2;
}

html[data-theme="dark"] .site-header {
  background: rgba(9, 18, 33, .94) !important;
  border-color: #253852 !important;
  box-shadow: 0 14px 36px rgba(0, 0, 0, .28) !important;
  backdrop-filter: blur(18px);
}

html[data-theme="dark"] :is(.brand, .main-nav a, .nav-toggle) {
  color: #edf4ff;
}

html[data-theme="dark"] .nav-toggle {
  background: #142238;
  border-color: #304766;
}

html[data-theme="dark"] .nav-toggle span {
  background: #edf4ff;
}

.theme-toggle {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 13px;
  color: #10234f;
  font: inherit;
  font-size: .88rem;
  font-weight: 800;
  background: #f4f8ff;
  border: 1px solid #d7e5f5;
  border-radius: 999px;
  cursor: pointer;
  transition: color .18s ease, background .18s ease, border-color .18s ease, transform .18s ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  border-color: #8fcaff;
}

.theme-toggle:focus-visible {
  outline: 3px solid rgba(70, 157, 255, .38);
  outline-offset: 3px;
}

.theme-toggle-icon {
  display: inline-grid;
  width: 20px;
  height: 20px;
  place-items: center;
  font-size: 1.05rem;
  line-height: 1;
}

html[data-theme="dark"] .theme-toggle {
  color: #eaf2ff;
  background: #182940;
  border-color: #365070;
}

html[data-theme="dark"] :is(
  .content-hero,
  .lesson-hero,
  .studio-hero,
  .exercise-module-shell,
  .legal-main,
  .legal-hero
) {
  color: #e9f0ff;
}

html[data-theme="dark"] :is(
  h1, h2, h3, h4,
  .content-hero h1,
  .lesson-hero h1,
  .studio-intro h1,
  .study-card h2,
  .lesson-anchor-title,
  .practice-question h2,
  .exercise-hero h1,
  .legal-hero h1
) {
  color: #f2f6ff !important;
}

html[data-theme="dark"] :is(
  p, li,
  .content-hero p,
  .lesson-hero p,
  .study-card p,
  .study-card li,
  .chapter-card p,
  .topic-card p,
  .quick-card p,
  .side-card p,
  .exercise-item h3,
  .practice-question p,
  .legal-main p,
  .legal-main li
) {
  color: #afbdd3;
}

html[data-theme="dark"] :is(
  .topic-card,
  .topic-panel,
  .overview-strip,
  .overview-card,
  .chapter-card,
  .side-card,
  .lesson-card,
  .quick-card,
  .content-visual,
  .lesson-visual-card,
  .graph-card,
  .studio-main,
  .study-card,
  .studio-side-card,
  .lesson-anchor-card,
  .practice-toolbar,
  .practice-question,
  .practice-result,
  .practice-answer-key,
  .exercise-item,
  .answer-highlight,
  .legal-card,
  .legal-section,
  .feedback-card
) {
  background: #111d31 !important;
  border-color: #2b3f5d !important;
  box-shadow: 0 16px 42px rgba(0, 0, 0, .2) !important;
}

html[data-theme="dark"] :is(
  .math-block,
  .big-formula,
  .formula-box,
  .formula-panel,
  .worked-panel,
  .mini-note,
  .note-box,
  .lesson-note,
  .practice-box,
  .element-set-box,
  .representation-example,
  .notation-example,
  .notation-note,
  .geometry-visual-card,
  .angle-classification-card,
  .angle-relation-grid > div,
  .ineq-visual-card
) {
  color: #e7efff !important;
  background: #15243a !important;
  border-color: #304766 !important;
}

html[data-theme="dark"] :is(.math-block, .math-text, .math-line, .big-formula, .formula-box) {
  color: #eaf2ff !important;
}

html[data-theme="dark"] :is(
  .lesson-table,
  .lesson-table th,
  .lesson-table td,
  .element-rules,
  .element-rules p,
  .representation-grid div,
  .notation-translate > div
) {
  color: #dce7f8 !important;
  background: #111d31 !important;
  border-color: #2c405f !important;
}

html[data-theme="dark"] :is(
  .exercise-options span,
  .answers button,
  .practice-filter,
  .lesson-question button,
  .button.secondary,
  .lesson-mobile-anchor-toggle
) {
  color: #dce8fb !important;
  background: #17263d !important;
  border-color: #365070 !important;
}

html[data-theme="dark"] :is(
  .exercise-options span:hover,
  .exercise-options span.is-selected,
  .answers button:hover,
  .practice-filter:hover,
  .practice-filter.is-active,
  .lesson-question button:hover
) {
  color: #f3f7ff !important;
  background: #203857 !important;
  border-color: #68aefc !important;
}

html[data-theme="dark"] :is(.breadcrumb, .breadcrumb a, .lesson-anchor-link, .practice-theory-link) {
  color: #86bdff;
}

html[data-theme="dark"] .lesson-anchor-link.active {
  color: #a8d2ff !important;
  background: #173253 !important;
  border-color: #3d6f9f !important;
}

html[data-theme="dark"] :is(.studio-kicker, .formula-caption, figcaption, .practice-topic, .practice-progress) {
  color: #9eafc8 !important;
}

html[data-theme="dark"] .geometry-visual-card svg [fill="#f8fbff"],
html[data-theme="dark"] .geometry-visual-card svg [fill="#fbfdff"],
html[data-theme="dark"] .geometry-visual-card svg [fill="#fff"] {
  fill: #101d31 !important;
}

html[data-theme="dark"] .geometry-visual-card svg [fill="#071943"],
html[data-theme="dark"] .geometry-visual-card svg [fill="#10204d"],
html[data-theme="dark"] .geometry-visual-card svg [fill="#12244d"] {
  fill: #edf4ff !important;
}

html[data-theme="dark"] .geometry-visual-card svg [stroke="#071943"],
html[data-theme="dark"] .geometry-visual-card svg [stroke="#10204d"],
html[data-theme="dark"] .geometry-visual-card svg [stroke="#12244d"] {
  stroke: #dce8fb !important;
}

html[data-theme="dark"] .geometry-visual-card svg > rect:first-of-type {
  fill: #101d31 !important;
  stroke: #304766 !important;
}

html[data-theme="dark"] .study-pet-message {
  color: #c4d2e6;
  background: linear-gradient(145deg, #17263d, #111d31) !important;
  border-color: #3a5575;
}

html[data-theme="dark"] .study-pet-message::after {
  background: #142238;
  border-color: #3a5575;
}

html[data-theme="dark"] footer,
html[data-theme="dark"] .site-footer {
  color: #9eafc8;
  background: #091426 !important;
  border-color: #243752 !important;
}

@media (max-width: 760px) {
  .theme-toggle {
    width: 100%;
    min-height: 46px;
    justify-content: flex-start;
    border-radius: 12px;
  }

  html[data-theme="dark"] .main-nav {
    background: #101d31 !important;
    border-color: #304766 !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle {
    transition: none;
  }
}

/* Complementos do modo noturno */
html[data-theme="dark"] :is(
  .path-card,
  .exercise-card,
  .legal-toc,
  .legal-hero,
  .legal-meta span,
  .method-item,
  .value-item
) {
  background: #111d31 !important;
  border-color: #2b3f5d !important;
  box-shadow: 0 16px 42px rgba(0, 0, 0, .2) !important;
}

html[data-theme="dark"] .legal-note {
  color: #f1dda0 !important;
  background: #302a18 !important;
  border-color: #6b5925 !important;
}

html[data-theme="dark"] :is(.legal-toc a, .legal-footer a) {
  color: #91c3ff;
}

html[data-theme="dark"] .legal-toc a:hover,
html[data-theme="dark"] .legal-toc a:focus-visible {
  color: #c7e1ff;
  background: #193454;
}

html[data-theme="dark"] :is(.home-image-hero img, .content-hero .hero-art-image) {
  filter: brightness(.74) saturate(.9) contrast(1.04);
}
