/* MathPro Tutors responsive hardening V31
   Loaded LAST. Desktop design stays intact; this layer only normalizes
   tablet/mobile layout, overflow, touch targets, forms, tables and portals. */

:root {
  --mpt31-gutter: clamp(14px, 4vw, 28px);
  --mpt31-touch: 44px;
}

html, body { max-width: 100%; overflow-x: clip; }
body.mathguru-theme *,
body.mathguru-theme *::before,
body.mathguru-theme *::after { box-sizing: border-box; }
body.mathguru-theme img,
body.mathguru-theme video,
body.mathguru-theme svg,
body.mathguru-theme canvas { max-width: 100%; height: auto; }
body.mathguru-theme iframe { max-width: 100%; }
body.mathguru-theme pre,
body.mathguru-theme code,
body.mathguru-theme .wrap-code,
body.mathguru-theme .secret-code { overflow-wrap: anywhere; word-break: break-word; }
body.mathguru-theme main { min-width: 0; }
body.mathguru-theme .container,
body.mathguru-theme .site-shell,
body.mathguru-theme .page-section { min-width: 0; }
body.mathguru-theme input,
body.mathguru-theme select,
body.mathguru-theme textarea { max-width: 100%; }
body.mathguru-theme button,
body.mathguru-theme .button,
body.mathguru-theme [role="button"] { touch-action: manipulation; }

/* Prevent wide rich content from breaking the viewport. */
body.mathguru-theme .responsive-table,
body.mathguru-theme .table-responsive,
body.mathguru-theme .table-wrap,
body.mathguru-theme .data-table-wrap,
body.mathguru-theme .calendar-scroll,
body.mathguru-theme .overflow-x-auto {
  max-width: 100%;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
}

/* ---------- Header / announcement / navigation ---------- */
@media (max-width: 1040px) {
  body.mathguru-theme .mgt-announcement {
    min-height: 0 !important;
    padding: 8px 42px 8px 0 !important;
  }
  body.mathguru-theme .mgt-announcement-inner {
    width: min(100% - 24px, 1180px) !important;
    gap: 4px 10px !important;
    font-size: .78rem !important;
    line-height: 1.35 !important;
  }
  body.mathguru-theme .mgt-announcement-dismiss {
    right: 10px !important;
    width: 36px !important;
    height: 36px !important;
  }

  body.mathguru-theme .mgt-reference-header,
  body.mathguru-theme.mp-homepage .mgt-reference-header {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    z-index: 80 !important;
    background: rgba(8, 10, 38, .96) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
  }
  body.mathguru-theme .mgt-header-inner {
    position: relative !important;
    width: min(100% - 26px, 1180px) !important;
    min-height: 72px !important;
    gap: 12px !important;
    padding-block: 8px !important;
  }
  body.mathguru-theme .mpt-logo-header {
    width: clamp(126px, 24vw, 154px) !important;
    max-height: 52px !important;
  }
  body.mathguru-theme .mgt-header-inner > .mpt-logo-brand {
    width: auto !important;
    min-width: 0 !important;
  }
  body.mathguru-theme .mpt-nav-toggle,
  body.mathguru-theme .pro-nav-toggle {
    display: inline-flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    width: 46px !important;
    height: 46px !important;
    margin-left: auto !important;
    padding: 9px !important;
    border: 1px solid rgba(255,255,255,.30) !important;
    border-radius: 10px !important;
    background: rgba(255,255,255,.06) !important;
  }
  body.mathguru-theme .mpt-nav-toggle > span,
  body.mathguru-theme .pro-nav-toggle > span {
    width: 100% !important;
    height: 2px !important;
    margin: 3px 0 !important;
    background: #fff !important;
  }
  body.mathguru-theme .mgt-reference-nav,
  body.mathguru-theme .mpt-header-nav,
  body.mathguru-theme .pro-header-nav {
    position: absolute !important;
    top: calc(100% + 1px) !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 90 !important;
    display: none !important;
    max-height: min(72vh, 650px) !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    padding: 14px !important;
    gap: 4px !important;
    flex-direction: column !important;
    align-items: stretch !important;
    background: rgba(8,10,38,.985) !important;
    border: 1px solid rgba(255,255,255,.12) !important;
    border-radius: 0 0 14px 14px !important;
    box-shadow: 0 26px 60px rgba(0,0,0,.28) !important;
  }
  body.mathguru-theme .mgt-reference-nav.is-open,
  body.mathguru-theme .mpt-header-nav.is-open,
  body.mathguru-theme .pro-header-nav.is-open { display: flex !important; }

  body.mathguru-theme .mgt-reference-nav > a,
  body.mathguru-theme .mgt-nav-parent,
  body.mathguru-theme .mgt-sign-in,
  body.mathguru-theme .mgt-sign-out {
    width: 100% !important;
    min-height: var(--mpt31-touch) !important;
    display: flex !important;
    align-items: center !important;
    padding: 10px 12px !important;
    border-radius: 8px !important;
    font-size: .94rem !important;
  }
  body.mathguru-theme .mgt-nav-dropdown { width: 100% !important; }
  body.mathguru-theme .mgt-dropdown-menu {
    position: static !important;
    display: grid !important;
    width: 100% !important;
    margin: 2px 0 6px !important;
    padding: 6px !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    box-shadow: none !important;
    border-radius: 8px !important;
    background: rgba(255,255,255,.055) !important;
  }
  body.mathguru-theme .mgt-dropdown-menu a {
    min-height: 40px !important;
    display: flex !important;
    align-items: center !important;
    padding: 8px 10px !important;
    font-size: .87rem !important;
  }
  body.mathguru-theme .mgt-header-actions {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    margin: 6px 0 0 !important;
  }
  body.mathguru-theme .mgt-header-actions form { width: 100% !important; }
  body.mathguru-theme .mgt-contact-cta,
  body.mathguru-theme .mgt-portal-cta,
  body.mathguru-theme .mgt-header-actions button {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 46px !important;
  }

  body.mathguru-theme.site-navigation-open { overflow: hidden !important; }
  body.mathguru-theme.mp-homepage .pro-home-hero { padding-top: clamp(64px, 9vw, 92px) !important; }
}

/* ---------- Homepage ---------- */
@media (max-width: 1024px) {
  body.mathguru-theme .pro-home-hero {
    min-height: 0 !important;
    padding: 72px 0 78px !important;
  }
  body.mathguru-theme .pro-home-hero-grid {
    grid-template-columns: 1fr !important;
    width: min(100% - 40px, 900px) !important;
    gap: 30px !important;
  }
  body.mathguru-theme .pro-home-hero-copy,
  body.mathguru-theme .pro-home-hero-copy h1,
  body.mathguru-theme .pro-home-hero-copy > p { max-width: 760px !important; }
  body.mathguru-theme .pro-home-hero-copy h1 {
    font-size: clamp(3rem, 8vw, 5rem) !important;
    line-height: .98 !important;
  }
  body.mathguru-theme .mpt-hero-video { object-position: center center !important; }

  body.mathguru-theme .pro-proof-bar .container {
    grid-template-columns: repeat(2, minmax(0,1fr)) !important;
  }
  body.mathguru-theme .pro-proof-bar span:nth-child(odd) { border-left: 0 !important; }

  body.mathguru-theme .mgt-feature-story-grid,
  body.mathguru-theme .mpt-space-showcase-grid {
    grid-template-columns: 1fr !important;
    gap: 38px !important;
  }
  body.mathguru-theme .mgt-feature-story-art,
  body.mathguru-theme .mpt-space-showcase-art {
    max-width: 680px !important;
    width: 100% !important;
    margin-inline: auto !important;
  }
  body.mathguru-theme .mgt-feature-story-copy,
  body.mathguru-theme .mpt-space-showcase-copy { max-width: 760px !important; }

  body.mathguru-theme .mpt-learning-card-grid,
  body.mathguru-theme .pro-course-grid,
  body.mathguru-theme .pro-tutor-grid {
    grid-template-columns: repeat(2, minmax(0,1fr)) !important;
  }

  body.mathguru-theme .pro-google-review-grid { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
  body.mathguru-theme .mpt-final-match-layout {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
  }
  body.mathguru-theme .mpt-final-match-form { width: 100% !important; }

  body.mathguru-theme .pro-footer-grid {
    grid-template-columns: 1.4fr repeat(2, 1fr) !important;
    gap: 32px 24px !important;
  }
}

@media (max-width: 768px) {
  body.mathguru-theme .pro-home-hero { padding: 56px 0 64px !important; }
  body.mathguru-theme .pro-home-hero-grid { width: min(100% - 30px, 900px) !important; }
  body.mathguru-theme .pro-home-hero-copy h1 {
    font-size: clamp(2.55rem, 12vw, 4rem) !important;
    letter-spacing: -.045em !important;
  }
  body.mathguru-theme .pro-home-hero-copy > p {
    font-size: .98rem !important;
    line-height: 1.58 !important;
  }
  body.mathguru-theme .mpt-hero-cta-row,
  body.mathguru-theme .pro-button-row,
  body.mathguru-theme .mgt-story-actions,
  body.mathguru-theme .mpt-space-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
    width: 100% !important;
    max-width: 560px !important;
  }
  body.mathguru-theme .mpt-hero-cta-row a,
  body.mathguru-theme .pro-button-row a,
  body.mathguru-theme .mgt-story-actions a,
  body.mathguru-theme .mpt-space-actions a { width: 100% !important; min-width: 0 !important; }

  body.mathguru-theme .pro-inline-trust {
    gap: 10px 16px !important;
    font-size: .84rem !important;
  }

  body.mathguru-theme .mgt-feature-story,
  body.mathguru-theme .mpt-space-showcase,
  body.mathguru-theme .pro-section { padding-block: 58px !important; }
  body.mathguru-theme .mgt-feature-story-copy h2,
  body.mathguru-theme .mpt-space-showcase-copy h2,
  body.mathguru-theme .pro-section-heading h2 {
    font-size: clamp(2rem, 8vw, 3rem) !important;
    line-height: 1.06 !important;
  }
  body.mathguru-theme .mpt-space-symbol,
  body.mathguru-theme .mpt-space-dot-grid { opacity: .32 !important; transform: scale(.82) !important; }

  body.mathguru-theme .mpt-learning-card-grid,
  body.mathguru-theme .pro-course-grid,
  body.mathguru-theme .pro-tutor-grid,
  body.mathguru-theme .pro-google-review-grid { grid-template-columns: 1fr !important; }

  body.mathguru-theme .pro-google-summary-bar {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 18px !important;
  }
  body.mathguru-theme .pro-google-review-cta { width: 100% !important; }

  body.mathguru-theme .mpt-final-match-form,
  body.mathguru-theme .pro-newsletter-form,
  body.mathguru-theme .pro-newsletter-name-row {
    grid-template-columns: 1fr !important;
    display: grid !important;
    gap: 12px !important;
  }
  body.mathguru-theme .pro-newsletter-section {
    min-height: 0 !important;
    padding: 64px 0 !important;
    background-position: center center !important;
  }
  body.mathguru-theme .pro-newsletter-section-inner { width: min(100% - 30px, 900px) !important; }
  body.mathguru-theme .pro-newsletter-copy h2 { font-size: clamp(2.2rem, 9vw, 3.6rem) !important; }
  body.mathguru-theme .pro-newsletter-cta,
  body.mathguru-theme .pro-newsletter-form button { width: 100% !important; min-height: 50px !important; }

  body.mathguru-theme .pro-footer-grid {
    grid-template-columns: repeat(2,minmax(0,1fr)) !important;
    gap: 30px 20px !important;
  }
  body.mathguru-theme .pro-footer-brand { grid-column: 1 / -1 !important; }
  body.mathguru-theme .pro-footer-bottom {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 7px !important;
  }
}

@media (max-width: 480px) {
  body.mathguru-theme .container { width: min(100% - 28px, 1180px) !important; }
  body.mathguru-theme .mgt-announcement-inner { font-size: .72rem !important; }
  body.mathguru-theme .mpt-logo-header { width: 126px !important; }

  body.mathguru-theme .pro-home-hero { padding: 48px 0 54px !important; }
  body.mathguru-theme .pro-home-hero-grid { width: min(100% - 28px, 900px) !important; }
  body.mathguru-theme .pro-home-hero-copy h1 { font-size: clamp(2.35rem, 13vw, 3.25rem) !important; }
  body.mathguru-theme .mpt-hero-video-shade { background: rgba(5,7,27,.46) !important; }
  body.mathguru-theme .mpt-hero-cta-row,
  body.mathguru-theme .pro-button-row,
  body.mathguru-theme .mgt-story-actions,
  body.mathguru-theme .mpt-space-actions { grid-template-columns: 1fr !important; }
  body.mathguru-theme .pro-inline-trust { display: grid !important; grid-template-columns: 1fr 1fr !important; }
  body.mathguru-theme .pro-proof-bar .container { grid-template-columns: 1fr !important; }
  body.mathguru-theme .pro-proof-bar span { border-left: 0 !important; border-top: 1px solid rgba(255,255,255,.18) !important; }
  body.mathguru-theme .mgt-feature-story-art,
  body.mathguru-theme .mpt-space-showcase-art { max-width: 100% !important; }
  body.mathguru-theme .mpt-space-symbol-formula,
  body.mathguru-theme .mpt-space-symbol-root,
  body.mathguru-theme .mpt-space-dot-grid { display: none !important; }
  body.mathguru-theme .mpt-learning-card,
  body.mathguru-theme .pro-course-card,
  body.mathguru-theme .pro-tutor-card,
  body.mathguru-theme .pro-google-review-card { padding: 20px !important; }
  body.mathguru-theme .pro-footer-grid { grid-template-columns: 1fr !important; }
  body.mathguru-theme .pro-footer-brand { grid-column: auto !important; }
  body.mathguru-theme .mpt-logo-footer { width: 190px !important; }
  body.mathguru-theme .pro-whatsapp-float {
    right: 10px !important;
    bottom: 10px !important;
    min-height: 44px !important;
    padding: 7px 10px !important;
  }
  body.mathguru-theme .pro-whatsapp-float strong { font-size: .72rem !important; }
}

/* ---------- Public/marketing pages ---------- */
@media (max-width: 900px) {
  body.mp-marketing-page:not(.mp-homepage) .pro-page-hero,
  body.mp-marketing-page:not(.mp-homepage) .mp-page-hero,
  body.mp-marketing-page .mpt-demo-hero,
  body.mp-marketing-page .mpt-country-hero { padding: 64px 0 !important; }

  body.mp-marketing-page:not(.mp-homepage) .pro-page-hero h1,
  body.mp-marketing-page:not(.mp-homepage) .mp-page-hero h1,
  body.mp-marketing-page .mpt-demo-copy h1,
  body.mp-marketing-page .mpt-country-hero h1 {
    font-size: clamp(2.5rem, 9vw, 4.25rem) !important;
  }

  body.mp-marketing-page .mpt-demo-hero-grid,
  body.mp-marketing-page .mpt-country-hero-grid,
  body.mp-marketing-page .mpt-demo-form-layout,
  body.mp-marketing-page .mp-contact-grid { grid-template-columns: 1fr !important; gap: 28px !important; }
  body.mp-marketing-page .mpt-demo-form-heading { position: static !important; }
  body.mp-marketing-page .mpt-country-placeholder-grid,
  body.mp-marketing-page .mpt-review-placeholder-grid { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
  body.mp-marketing-page .mpt-demo-note,
  body.mp-marketing-page .mpt-country-placeholder { max-width: 680px !important; }

  body.mathguru-theme:not(.mp-homepage) .checkout-shell,
  body.mathguru-theme:not(.mp-homepage) .phase2-checkout-shell,
  body.mathguru-theme:not(.mp-homepage) .phase3-enrollment-shell {
    width: min(100% - 28px, 1180px) !important;
  }
}

@media (max-width: 640px) {
  body.mp-marketing-page:not(.mp-homepage) .pro-page-hero,
  body.mp-marketing-page:not(.mp-homepage) .mp-page-hero,
  body.mp-marketing-page .mpt-demo-hero,
  body.mp-marketing-page .mpt-country-hero { padding: 52px 0 !important; }
  body.mp-marketing-page:not(.mp-homepage) .pro-page-hero h1,
  body.mp-marketing-page:not(.mp-homepage) .mp-page-hero h1,
  body.mp-marketing-page .mpt-demo-copy h1,
  body.mp-marketing-page .mpt-country-hero h1 { font-size: clamp(2.25rem, 11vw, 3.25rem) !important; }
  body.mp-marketing-page .mpt-demo-form,
  body.mp-marketing-page .mpt-country-placeholder-grid,
  body.mp-marketing-page .mpt-review-placeholder-grid { grid-template-columns: 1fr !important; }
  body.mp-marketing-page .mpt-demo-form .span-2 { grid-column: auto !important; }
  body.mp-marketing-page .mpt-demo-form-card,
  body.mp-marketing-page .mpt-country-placeholder,
  body.mp-marketing-page .mp-contact-grid .card { padding: 20px !important; border-radius: 18px !important; }
  body.mp-marketing-page .mpt-review-empty-panel { flex-direction: column !important; align-items: flex-start !important; }
}

/* ---------- Authentication / registration ---------- */
@media (max-width: 900px) {
  body.mp-auth-route .mpt-auth-page { padding: 38px 0 56px !important; }
  body.mp-auth-route .mpt-auth-shell,
  body.mp-auth-route .mpt-register-shell {
    width: min(100% - 30px, 760px) !important;
    grid-template-columns: 1fr !important;
    border-radius: 22px !important;
  }
  body.mp-auth-route .mpt-auth-brand-panel,
  body.mp-auth-route .mpt-register-intro { padding: 34px !important; }
  body.mp-auth-route .mpt-auth-brand-panel h1,
  body.mp-auth-route .mpt-register-intro h1 { font-size: clamp(2.2rem, 8vw, 3.5rem) !important; }
  body.mp-auth-route .mpt-auth-card,
  body.mp-auth-route .mpt-register-card { padding: 34px !important; }
}

@media (max-width: 720px) {
  body.mp-auth-route .mpt-register-form,
  body.mp-auth-route .mpt-register-form.inner-grid,
  body.mp-auth-route .form-grid,
  body.mp-auth-route .check-grid { grid-template-columns: 1fr !important; }
  body.mp-auth-route .mpt-register-form .span-2,
  body.mp-auth-route .span-2 { grid-column: auto !important; }
  body.mp-auth-route .mpt-auth-account-actions { grid-template-columns: 1fr !important; }
  body.mp-auth-route .mpt-auth-links { flex-wrap: wrap !important; }
}

@media (max-width: 480px) {
  body.mp-auth-route .mpt-auth-page { padding: 22px 0 40px !important; }
  body.mp-auth-route .mpt-auth-shell,
  body.mp-auth-route .mpt-register-shell { width: min(100% - 18px, 760px) !important; border-radius: 16px !important; }
  body.mp-auth-route .mpt-auth-brand-panel,
  body.mp-auth-route .mpt-register-intro { padding: 26px 20px !important; }
  body.mp-auth-route .mpt-auth-card,
  body.mp-auth-route .mpt-register-card { padding: 26px 18px !important; }
  body.mp-auth-route .mpt-auth-feature-list { margin: 20px 0 !important; }
  body.mp-auth-route .mpt-auth-links { flex-direction: column !important; gap: 8px !important; }
  body.mp-auth-route .mpt-guardian-fields { padding: 14px !important; }
  body.mp-auth-route input:not([type="checkbox"]),
  body.mp-auth-route select,
  body.mp-auth-route textarea,
  body.mp-auth-route .button { min-height: 48px !important; }
}

/* ---------- Generic forms, account pages, checkout and utilities ---------- */
@media (max-width: 850px) {
  body.mathguru-theme .two-column,
  body.mathguru-theme .three-column,
  body.mathguru-theme .form-grid.two,
  body.mathguru-theme .form-grid.three,
  body.mathguru-theme .finance-layout,
  body.mathguru-theme .access-grid,
  body.mathguru-theme .application-card { grid-template-columns: 1fr !important; }
  body.mathguru-theme .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
  body.mathguru-theme .card-heading,
  body.mathguru-theme .split-heading,
  body.mathguru-theme .page-heading,
  body.mathguru-theme .action-row,
  body.mathguru-theme .toolbar,
  body.mathguru-theme .filter-row {
    flex-wrap: wrap !important;
    align-items: flex-start !important;
  }
  body.mathguru-theme .inline-form { grid-template-columns: 1fr !important; }
}

@media (max-width: 560px) {
  body.mathguru-theme .metric-grid,
  body.mathguru-theme .feature-grid,
  body.mathguru-theme .role-grid,
  body.mathguru-theme .conflict-grid { grid-template-columns: 1fr !important; }
  body.mathguru-theme .action-row,
  body.mathguru-theme .actions,
  body.mathguru-theme .button-row { display: grid !important; grid-template-columns: 1fr !important; width: 100% !important; }
  body.mathguru-theme .action-row .button,
  body.mathguru-theme .actions .button,
  body.mathguru-theme .button-row .button { width: 100% !important; }
  body.mathguru-theme fieldset { padding: 14px !important; }
}

/* ---------- Admin pages ---------- */
@media (max-width: 1024px) {
  body.mp-admin-route:not(.mp-portal-dashboard) main#main-content { padding: 28px 0 54px !important; }
  body.mp-admin-route:not(.mp-portal-dashboard) main#main-content > .container,
  body.mp-admin-route:not(.mp-portal-dashboard) main#main-content > .page-section {
    width: min(100% - 28px, 1240px) !important;
  }
  body.mp-admin-route .form-grid,
  body.mp-admin-route .settings-form-grid,
  body.mp-admin-route .grid.grid-2,
  body.mp-admin-route .grid-two { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
  body.mp-admin-route .mpt-demo-admin-grid { grid-template-columns: 1fr !important; }

  body.mp-portal-dashboard .admin-dashboard-main,
  body.mp-portal-dashboard .teacher-dashboard-main,
  body.mp-portal-dashboard .student-dashboard-main { min-width: 0 !important; }
  body.mp-portal-dashboard .admin-dashboard-hero,
  body.mp-portal-dashboard .teacher-dashboard-hero,
  body.mp-portal-dashboard .student-dashboard-hero {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 18px !important;
  }
  body.mp-portal-dashboard .admin-hero-actions,
  body.mp-portal-dashboard .teacher-hero-actions,
  body.mp-portal-dashboard .student-hero-actions { flex-wrap: wrap !important; justify-content: flex-start !important; }
  body.mp-portal-dashboard .admin-metric-grid,
  body.mp-portal-dashboard .teacher-summary-grid,
  body.mp-portal-dashboard .student-summary-grid { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
  body.mp-portal-dashboard .pro-admin-action-grid,
  body.mp-portal-dashboard .admin-queue-grid,
  body.mp-portal-dashboard .pro-admin-lower-grid,
  body.mp-portal-dashboard .teacher-dashboard-primary-grid,
  body.mp-portal-dashboard .teacher-dashboard-secondary-grid,
  body.mp-portal-dashboard .student-support-grid { grid-template-columns: 1fr !important; }
}

@media (max-width: 720px) {
  body.mp-admin-route .form-grid,
  body.mp-admin-route .settings-form-grid,
  body.mp-admin-route .grid.grid-2,
  body.mp-admin-route .grid-two { grid-template-columns: 1fr !important; }
  body.mp-admin-route .card,
  body.mp-admin-route .panel,
  body.mp-admin-route .settings-panel,
  body.mp-admin-route .phase2-admin-panel,
  body.mp-admin-route .phase3-panel { padding: 16px !important; }
  body.mp-admin-route .mpt-demo-admin-item { padding: 18px !important; }
  body.mp-admin-route .mpt-demo-admin-item > header { flex-direction: column !important; }
  body.mp-admin-route .mpt-demo-status-form { flex-direction: column !important; align-items: stretch !important; }
  body.mp-admin-route .mpt-demo-status-form label { min-width: 0 !important; }

  body.mp-admin-route table,
  body.mp-portal-route table,
  body.mp-portal-dashboard table {
    display: block !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  body.mp-admin-route th,
  body.mp-admin-route td,
  body.mp-portal-route th,
  body.mp-portal-route td { padding: 10px 11px !important; }

  body.mp-portal-dashboard .admin-dashboard-main,
  body.mp-portal-dashboard .teacher-dashboard-main,
  body.mp-portal-dashboard .student-dashboard-main { padding: 16px 12px 76px !important; }
  body.mp-portal-dashboard .admin-dashboard-hero,
  body.mp-portal-dashboard .teacher-dashboard-hero,
  body.mp-portal-dashboard .student-dashboard-hero { padding: 20px !important; border-radius: 16px !important; }
  body.mp-portal-dashboard .admin-dashboard-hero h1,
  body.mp-portal-dashboard .teacher-dashboard-hero h1,
  body.mp-portal-dashboard .student-dashboard-hero h1 { font-size: clamp(2rem, 9vw, 3rem) !important; }
  body.mp-portal-dashboard .admin-metric-grid,
  body.mp-portal-dashboard .teacher-summary-grid,
  body.mp-portal-dashboard .student-summary-grid { grid-template-columns: 1fr !important; }
  body.mp-portal-dashboard .admin-hero-actions,
  body.mp-portal-dashboard .teacher-hero-actions,
  body.mp-portal-dashboard .student-hero-actions { display: grid !important; grid-template-columns: 1fr !important; width: 100% !important; }
  body.mp-portal-dashboard .admin-hero-actions .button,
  body.mp-portal-dashboard .teacher-hero-actions .button,
  body.mp-portal-dashboard .student-hero-actions .button { width: 100% !important; }
  body.mp-portal-dashboard .admin-mobile-nav-toggle,
  body.mp-portal-dashboard .teacher-mobile-nav-toggle,
  body.mp-portal-dashboard .student-mobile-nav-toggle {
    min-height: 48px !important;
    max-width: calc(100vw - 24px) !important;
  }
}

/* ---------- Student / parent / teacher non-dashboard portal pages ---------- */
@media (max-width: 850px) {
  body.mp-portal-route main#main-content > .container,
  body.mp-portal-route main#main-content > .page-section { width: min(100% - 28px, 1180px) !important; }
  body.mp-portal-route .student-panel,
  body.mp-portal-route .teacher-panel,
  body.mp-portal-route .parent-panel,
  body.mp-portal-route .student-summary-card,
  body.mp-portal-route .teacher-summary-card,
  body.mp-portal-route .parent-summary-card { min-width: 0 !important; }
  body.mp-portal-route .quick-action-list,
  body.mp-portal-route .student-summary-grid,
  body.mp-portal-route .teacher-summary-grid,
  body.mp-portal-route .parent-summary-grid { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
}

@media (max-width: 560px) {
  body.mp-portal-route .quick-action-list,
  body.mp-portal-route .student-summary-grid,
  body.mp-portal-route .teacher-summary-grid,
  body.mp-portal-route .parent-summary-grid { grid-template-columns: 1fr !important; }
  body.mp-portal-route .student-panel,
  body.mp-portal-route .teacher-panel,
  body.mp-portal-route .parent-panel { padding: 16px !important; }
}

/* ---------- Error pages ---------- */
@media (max-width: 640px) {
  body.mathguru-theme .error-page { padding: 52px 16px !important; }
  body.mathguru-theme .error-code { font-size: clamp(4rem, 22vw, 7rem) !important; }
  body.mathguru-theme .error-page h1 { font-size: clamp(2rem, 10vw, 3rem) !important; }
  body.mathguru-theme .request-id { max-width: 100% !important; overflow-wrap: anywhere !important; }
}

/* Short-height phones/tablets: avoid giant fixed vertical sections. */
@media (max-height: 700px) and (max-width: 900px) {
  body.mathguru-theme .pro-home-hero { min-height: 0 !important; }
  body.mp-auth-route .mpt-auth-page { padding-block: 24px !important; }
}

/* Respect reduced-motion preference across the site. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  body.mathguru-theme *,
  body.mathguru-theme *::before,
  body.mathguru-theme *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
