:root,
html[data-theme="dark"] {
  --theme-page-landing:
    radial-gradient(circle at 10% 10%, rgba(201, 119, 63, 0.14), transparent 26%),
    radial-gradient(circle at 88% 14%, rgba(41, 93, 98, 0.12), transparent 24%),
    linear-gradient(180deg, #f6efe4 0%, #ede3d4 100%);
  --theme-page-policy:
    radial-gradient(circle at 10% 10%, rgba(201, 119, 63, 0.12), transparent 24%),
    linear-gradient(180deg, #f7f0e6 0%, #ece2d4 100%);
  --theme-page-app:
    radial-gradient(circle at 12% 12%, rgba(201, 119, 63, 0.12), transparent 22%),
    radial-gradient(circle at 86% 10%, rgba(107, 157, 166, 0.12), transparent 18%),
    linear-gradient(180deg, #182534 0%, #13202d 46%, #101a26 100%);
  --theme-page-text: #172433;
  --theme-card-bg: linear-gradient(180deg, rgba(20, 32, 45, 0.97), rgba(14, 24, 35, 0.94));
  --theme-card-border: rgba(255, 245, 232, 0.14);
  --theme-card-text: #fffaf2;
  --theme-card-muted: rgba(255, 244, 229, 0.74);
  --theme-card-muted-soft: rgba(255, 244, 229, 0.58);
  --theme-card-shadow: 0 24px 64px rgba(8, 14, 21, 0.22);
  --theme-header-bg: linear-gradient(180deg, rgba(14, 23, 34, 0.96), rgba(20, 31, 44, 0.92));
  --theme-header-border: rgba(255, 245, 232, 0.14);
  --theme-header-text: #fffdf8;
  --theme-header-muted: rgba(255, 244, 229, 0.72);
  --theme-header-shadow: 0 24px 64px rgba(8, 14, 21, 0.2);
  --theme-brand-mark-bg:
    linear-gradient(135deg, rgba(201, 119, 63, 0.28), rgba(41, 93, 98, 0.24)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.06));
  --theme-brand-mark-border: rgba(255, 245, 232, 0.16);
  --theme-brand-mark-text: #fffdf8;
  --theme-secondary-bg: rgba(255, 255, 255, 0.07);
  --theme-secondary-border: rgba(255, 245, 232, 0.16);
  --theme-secondary-text: #fffaf2;
  --theme-secondary-active-bg: rgba(107, 157, 166, 0.16);
  --theme-secondary-active-border: rgba(107, 157, 166, 0.28);
  --theme-input-bg: rgba(255, 255, 255, 0.06);
  --theme-input-border: rgba(255, 245, 232, 0.16);
  --theme-input-text: #fffaf2;
  --theme-table-head-bg: rgba(255, 255, 255, 0.07);
  --theme-table-cell-bg: rgba(255, 255, 255, 0.03);
  --theme-mark-bg: rgba(201, 119, 63, 0.26);
  --theme-theme-switcher-bg: rgba(14, 23, 34, 0.9);
  --theme-theme-switcher-border: rgba(255, 245, 232, 0.14);
  --theme-theme-switcher-text: #fffdf8;
  --theme-theme-switcher-muted: rgba(255, 244, 229, 0.66);
  --theme-theme-switcher-button-bg: rgba(255, 255, 255, 0.07);
  --theme-theme-switcher-button-border: rgba(255, 245, 232, 0.12);
  --theme-theme-switcher-button-active-bg: rgba(255, 255, 255, 0.14);
  --theme-theme-switcher-button-active-border: rgba(255, 245, 232, 0.22);
  --theme-footer-text: #172433;
}

html[data-theme="light"] {
  --theme-page-landing:
    radial-gradient(circle at 12% 10%, rgba(201, 119, 63, 0.12), transparent 24%),
    radial-gradient(circle at 84% 14%, rgba(41, 93, 98, 0.1), transparent 20%),
    linear-gradient(180deg, #fbf7ef 0%, #efe6d9 100%);
  --theme-page-policy:
    radial-gradient(circle at 12% 10%, rgba(201, 119, 63, 0.1), transparent 20%),
    linear-gradient(180deg, #fcf8f1 0%, #efe5d8 100%);
  --theme-page-app:
    radial-gradient(circle at 12% 12%, rgba(201, 119, 63, 0.08), transparent 20%),
    radial-gradient(circle at 86% 10%, rgba(107, 157, 166, 0.08), transparent 16%),
    linear-gradient(180deg, #f7f1e7 0%, #ebe1d4 100%);
  --theme-page-text: #172433;
  --theme-card-bg: linear-gradient(180deg, rgba(255, 252, 247, 0.98), rgba(244, 236, 226, 0.96));
  --theme-card-border: rgba(23, 36, 51, 0.14);
  --theme-card-text: #172433;
  --theme-card-muted: #526373;
  --theme-card-muted-soft: #677788;
  --theme-card-shadow: 0 22px 52px rgba(20, 32, 45, 0.08);
  --theme-header-bg: linear-gradient(180deg, rgba(255, 252, 247, 0.94), rgba(247, 240, 230, 0.92));
  --theme-header-border: rgba(23, 36, 51, 0.12);
  --theme-header-text: #172433;
  --theme-header-muted: #526373;
  --theme-header-shadow: 0 18px 44px rgba(20, 32, 45, 0.08);
  --theme-brand-mark-bg:
    linear-gradient(135deg, rgba(201, 119, 63, 0.18), rgba(41, 93, 98, 0.14)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(243, 231, 216, 0.92));
  --theme-brand-mark-border: rgba(23, 36, 51, 0.12);
  --theme-brand-mark-text: #172433;
  --theme-secondary-bg: rgba(255, 255, 255, 0.84);
  --theme-secondary-border: rgba(23, 36, 51, 0.16);
  --theme-secondary-text: #172433;
  --theme-secondary-active-bg: rgba(107, 157, 166, 0.14);
  --theme-secondary-active-border: rgba(41, 93, 98, 0.22);
  --theme-input-bg: rgba(255, 255, 255, 0.94);
  --theme-input-border: rgba(23, 36, 51, 0.16);
  --theme-input-text: #172433;
  --theme-table-head-bg: rgba(23, 36, 51, 0.06);
  --theme-table-cell-bg: rgba(255, 255, 255, 0.56);
  --theme-mark-bg: rgba(201, 119, 63, 0.2);
  --theme-theme-switcher-bg: rgba(255, 252, 247, 0.94);
  --theme-theme-switcher-border: rgba(23, 36, 51, 0.12);
  --theme-theme-switcher-text: #172433;
  --theme-theme-switcher-muted: #526373;
  --theme-theme-switcher-button-bg: rgba(255, 255, 255, 0.82);
  --theme-theme-switcher-button-border: rgba(23, 36, 51, 0.12);
  --theme-theme-switcher-button-active-bg: rgba(23, 36, 51, 0.08);
  --theme-theme-switcher-button-active-border: rgba(23, 36, 51, 0.14);
  --theme-footer-text: #172433;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

html[data-theme="light"] {
  color-scheme: light;
}

body.landing-body {
  background: var(--theme-page-landing) !important;
  color: var(--theme-page-text) !important;
}

body.policy-body {
  background: var(--theme-page-policy) !important;
  color: var(--theme-page-text) !important;
}

body.app-body,
body.admin-body {
  background: var(--theme-page-app) !important;
  color: var(--theme-header-text) !important;
}

body.landing-body .card,
body.landing-body .hero-study-card,
body.landing-body .hero-metric-card,
body.landing-body .landing-feature-card,
body.landing-body .subject-card,
body.landing-body .trust-card,
body.landing-body .compare-card,
body.landing-body .landing-flow-step,
body.app-body .card,
body.app-body .chapter-launch-panel,
body.app-body .study-track-card,
body.app-body .chapter-launch-card,
body.app-body .workspace-hero-stat,
body.app-body .practice-assist-card,
body.app-body .review-block,
body.app-body .review-scorecard,
body.app-body .review-callout,
body.app-body .model-answer,
body.app-body .detail-explanation,
body.app-body .study-section-card,
body.app-body .study-item-card,
body.app-body .session-review-card,
body.admin-body .card,
body.admin-body .admin-entry,
body.admin-body .admin-panel-block,
body.policy-body .policy-card {
  background: var(--theme-card-bg) !important;
  border-color: var(--theme-card-border) !important;
  color: var(--theme-card-text) !important;
  box-shadow: var(--theme-card-shadow) !important;
}

body.landing-body .card *,
body.landing-body .hero-study-card *,
body.landing-body .hero-metric-card *,
body.landing-body .landing-feature-card *,
body.landing-body .subject-card *,
body.landing-body .trust-card *,
body.landing-body .compare-card *,
body.landing-body .landing-flow-step *,
body.app-body .card *,
body.app-body .chapter-launch-panel *,
body.app-body .study-track-card *,
body.app-body .chapter-launch-card *,
body.app-body .workspace-hero-stat *,
body.app-body .practice-assist-card *,
body.app-body .review-block *,
body.app-body .review-scorecard *,
body.app-body .review-callout *,
body.app-body .model-answer *,
body.app-body .detail-explanation *,
body.app-body .study-section-card *,
body.app-body .study-item-card *,
body.app-body .session-review-card *,
body.admin-body .card *,
body.admin-body .admin-entry *,
body.admin-body .admin-panel-block *,
body.policy-body .policy-card * {
  color: inherit;
}

body.landing-body .card p,
body.landing-body .card li,
body.landing-body .card .lead,
body.landing-body .card .mini,
body.app-body .card p,
body.app-body .card li,
body.app-body .card .lead,
body.app-body .card .mini,
body.app-body .chapter-launch-panel p,
body.admin-body .card p,
body.admin-body .card li,
body.admin-body .card .lead,
body.admin-body .card .mini,
body.policy-body .policy-card p,
body.policy-body .policy-card li,
body.policy-body .policy-card .lead,
body.policy-body .policy-card .mini,
.chapter-status,
.study-section-lead,
.chapter-launch-summary,
.chapter-launch-lead,
.chapter-study-rail-summary,
.chapter-study-rail-status,
.study-empty,
.review-line,
.review-score-copy,
.study-item-copy,
.study-item-subcopy,
.policy-intro,
.policy-section p,
.policy-list,
.admin-copy,
.admin-summary,
.session-card-mini,
.session-question-copy,
.session-area-meta,
.workspace-hero-stat span,
.hero-metric-card span,
.landing-feature-card p,
.subject-card p,
.trust-card p,
.compare-list,
.landing-flow-step p {
  color: var(--theme-card-muted) !important;
}

body.landing-body .card h1,
body.landing-body .card h2,
body.landing-body .card h3,
body.landing-body .card h4,
body.app-body .card h1,
body.app-body .card h2,
body.app-body .card h3,
body.app-body .card h4,
body.admin-body .card h1,
body.admin-body .card h2,
body.admin-body .card h3,
body.admin-body .card h4,
body.policy-body .policy-card h1,
body.policy-body .policy-card h2,
body.policy-body .policy-card h3,
body.policy-body .policy-card h4 {
  color: var(--theme-card-text) !important;
}

.landing-topbar,
.site-nav {
  background: var(--theme-header-bg) !important;
  border-color: var(--theme-header-border) !important;
  box-shadow: var(--theme-header-shadow) !important;
}

.landing-topbar {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: center !important;
  position: sticky;
  top: 16px;
  z-index: 32;
  padding: 0.85rem 1rem !important;
  border-radius: 24px !important;
  backdrop-filter: blur(18px);
}

.landing-topbar .brand-mark,
.site-nav .brand-mark {
  width: 42px !important;
  height: 42px !important;
  border-radius: 14px !important;
  background: var(--theme-brand-mark-bg) !important;
  border-color: var(--theme-brand-mark-border) !important;
  color: var(--theme-brand-mark-text) !important;
}

.landing-topbar .badge,
.landing-topbar .brand-title,
.site-nav .badge,
.site-nav-title,
.site-nav-link,
.auth-status,
.auth-session-label,
.auth-session-name,
.auth-session-email {
  color: var(--theme-header-text) !important;
}

.landing-topbar .brand-lockup {
  gap: 0.75rem;
  min-width: 0 !important;
}

.site-nav {
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-areas:
    "brand"
    "nav"
    "actions";
  gap: 0.9rem 1rem !important;
  align-items: start !important;
  padding: 1rem 1.1rem !important;
  border-radius: 26px !important;
}

.site-nav-primary {
  grid-area: brand !important;
  display: grid !important;
  gap: 0.55rem !important;
  justify-items: start !important;
  min-width: 0 !important;
}

.site-nav-brand {
  gap: 0.75rem !important;
  flex: 0 0 auto;
  min-width: 0 !important;
}

.site-nav-brand-copy {
  gap: 0.15rem !important;
}

.site-nav-title {
  font-size: 1.02rem !important;
}

.site-nav-subtitle {
  margin: 0 !important;
  max-width: 34ch !important;
  font-size: 0.82rem !important;
  line-height: 1.45 !important;
  color: var(--theme-header-muted) !important;
}

.site-nav-links {
  grid-area: nav !important;
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 0.55rem !important;
  padding-top: 0.05rem !important;
  width: 100% !important;
  min-width: 0 !important;
}

.site-nav-actions {
  grid-area: actions !important;
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  justify-content: flex-start !important;
  align-self: stretch !important;
  gap: 0.6rem !important;
  width: 100% !important;
  min-width: 0 !important;
}

.landing-topbar-actions,
.admin-actions,
.auth-actions {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  gap: 0.6rem !important;
  min-width: 0 !important;
}

.landing-topbar-actions {
  justify-content: flex-end !important;
}

.site-nav > *,
.landing-topbar > *,
.shell-topbar > *,
.auth-panel > * {
  min-width: 0 !important;
}

.site-nav-link {
  min-height: 40px !important;
  padding: 0.65rem 0.9rem !important;
  border-color: transparent !important;
  color: var(--theme-header-muted) !important;
}

.site-nav-link:hover,
.site-nav-link:focus-visible,
.site-nav-link.is-active {
  background: var(--theme-secondary-bg) !important;
  border-color: var(--theme-secondary-border) !important;
  color: var(--theme-header-text) !important;
}

.site-nav-actions .btn,
.landing-topbar-actions .btn {
  min-height: 42px !important;
  padding: 0.68rem 0.95rem !important;
}

.auth-session {
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr) auto !important;
  align-items: center !important;
  gap: 0.6rem !important;
  max-width: 100% !important;
  padding: 0.38rem 0.45rem 0.38rem 0.38rem !important;
  border-radius: 18px !important;
  background: var(--theme-secondary-bg) !important;
  border-color: var(--theme-secondary-border) !important;
}

.auth-session-copy {
  min-width: 0 !important;
}

.auth-session-name,
.auth-session-email {
  overflow-wrap: anywhere !important;
}

.profile-avatar {
  width: 38px !important;
  height: 38px !important;
  border-radius: 12px !important;
}

.auth-status {
  flex: 1 1 100%;
  max-width: 18ch;
  text-align: left;
  color: var(--theme-header-muted) !important;
}

.shell-topbar {
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: start !important;
}

.auth-panel {
  min-width: 0 !important;
  align-items: stretch !important;
}

.auth-profile {
  width: min(100%, 28rem);
  justify-self: end !important;
}

.auth-actions {
  justify-content: flex-end !important;
}

.btn-primary {
  color: var(--theme-header-text) !important;
}

.btn-secondary,
.btn-hint,
.btn-danger,
.chapter-track-tab,
.option-btn,
.order-item,
.match-row,
.practice-assist-meta,
.study-callout,
.study-formula,
.policy-link,
.auth-pill,
.study-pill,
.trust-pill,
.session-band-pill,
.session-question-row {
  background: var(--theme-secondary-bg) !important;
  color: var(--theme-secondary-text) !important;
  border-color: var(--theme-secondary-border) !important;
}

.btn-hint {
  background: var(--theme-secondary-active-bg) !important;
  border-color: var(--theme-secondary-active-border) !important;
}

.btn-danger {
  background: rgba(162, 71, 79, 0.18) !important;
}

input,
select,
textarea,
.challenge-input,
.answer-input,
.answer-editor {
  color: var(--theme-input-text) !important;
  background: var(--theme-input-bg) !important;
  border-color: var(--theme-input-border) !important;
  box-shadow: none !important;
}

::placeholder {
  color: var(--theme-card-muted-soft) !important;
}

.option-btn.is-selected {
  background: var(--theme-secondary-active-bg) !important;
  color: var(--theme-secondary-text) !important;
  border-color: var(--theme-secondary-active-border) !important;
}

.review-table th,
.review-table td,
.admin-table th,
.admin-table td {
  color: var(--theme-card-text) !important;
  border-color: var(--theme-card-border) !important;
}

.review-table th,
.admin-table th {
  background: var(--theme-table-head-bg) !important;
}

.review-table td,
.admin-table td {
  background: var(--theme-table-cell-bg) !important;
}

.model-answer-text mark,
.review-table mark {
  color: var(--theme-card-text) !important;
  background: var(--theme-mark-bg) !important;
}

.review-score-pill,
.session-question-score {
  color: var(--theme-card-text) !important;
  background: var(--theme-secondary-bg) !important;
}

.session-area-track,
.progress-track {
  background: color-mix(in srgb, var(--theme-card-text) 10%, transparent) !important;
}

.hud p {
  color: var(--theme-card-text) !important;
  background: color-mix(in srgb, var(--theme-card-text) 6%, transparent) !important;
  border-color: var(--theme-card-border) !important;
}

.landing-footer,
.landing-footer a {
  color: var(--theme-footer-text) !important;
}

.theme-switcher {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.theme-switcher.is-inline {
  margin-left: 0.1rem;
}

.theme-switcher.is-floating {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 14px;
  border: 1px solid var(--theme-theme-switcher-button-border);
  background: var(--theme-theme-switcher-button-bg);
  color: var(--theme-theme-switcher-text);
  box-shadow: 0 16px 40px rgba(8, 14, 21, 0.16);
  backdrop-filter: blur(18px);
  cursor: pointer;
  transition:
    background 180ms ease,
    border-color 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  background: var(--theme-theme-switcher-button-active-bg);
  border-color: var(--theme-theme-switcher-button-active-border);
  transform: translateY(-1px);
}

.theme-toggle:focus-visible {
  box-shadow: 0 0 0 3px rgba(201, 119, 63, 0.18);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle[data-theme-state="dark"] {
  background: rgba(255, 255, 255, 0.06);
}

.theme-toggle[data-theme-state="light"] {
  background: rgba(255, 255, 255, 0.78);
}

@media (max-width: 980px) {
  .landing-topbar,
  .shell-topbar,
  .site-nav {
    grid-template-columns: 1fr !important;
  }

  .site-nav-primary {
    justify-items: start !important;
  }

  .site-nav-subtitle,
  .auth-status {
    max-width: none !important;
    text-align: left !important;
  }

  .site-nav-actions {
    justify-content: flex-start !important;
    align-self: stretch !important;
  }

  .landing-topbar-actions,
  .admin-actions,
  .auth-actions {
    justify-content: flex-start !important;
  }

  .auth-panel {
    justify-items: start !important;
    text-align: left !important;
  }

  .auth-profile {
    justify-self: start !important;
    width: 100% !important;
  }
}

@media (max-width: 760px) {
  .landing-topbar {
    position: static !important;
  }

  .landing-topbar,
  .site-nav {
    border-radius: 22px !important;
  }

  .auth-session {
    grid-template-columns: auto minmax(0, 1fr) !important;
  }

  .profile-logout-btn {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .theme-switcher.is-floating {
    right: 14px;
    bottom: 14px;
  }
}
