/* Shared layout safeguards. Keep the established desktop design and palette. */
.hero-grid > *, .section-head > *, .why-layout > *, .review-grid > *,
.collaboration-tools > *, .closing-inner > *, .footer-content > *,
.subject-card > *, .directory-fields > *, .about-introduction > *,
.about-teaching > *, .instruction-method-heading > * { min-width: 0; }
.button, .text-link, .subject-book { max-width: 100%; overflow-wrap: break-word; }
.profile-breadcrumb, .lesson-toolbar, .directory-result-bar { flex-wrap: wrap; }
.course-button { min-width: 0; }
.course-button span { min-width: 0; overflow-wrap: break-word; }
.memory-panel { min-width: 0; flex-wrap: wrap; }
.memory-cell { min-width: 0; overflow-wrap: anywhere; }
.footer-content { grid-template-columns: minmax(0,1.65fr) repeat(2,minmax(0,1fr)); }
.footer-nav a, .footer-legal a { font-size: .875rem; min-height: 28px; display: inline-flex; align-items: center; }
.footer-nav { gap: 4px; }
.footer-nav h2 { font-size: .875rem; }
.footer-legal { flex-wrap: wrap; }
@media (any-pointer: coarse) {
 .footer-nav a, .footer-legal a { min-height: 44px; }
 .footer-nav { gap: 0; }
}
.lesson-controls button, .directory-categories button, .directory-clear,
.subject-details summary, .legal-sidebar a { min-height: 44px; }
.lesson-controls input[type="range"] { min-width: 0; min-height: 44px; flex-basis: 150px; max-width: 100%; }
.goal-select { font-size: 1rem; min-height: 48px; }
.sort-bars { gap: clamp(6px,1.5vw,20px); }
.sort-column { min-width: 0; width: auto; flex: 1 1 0; max-width: 61px; }
.sort-value, .sort-index { font-variant-numeric: tabular-nums; }
.proof-row { min-width: 0; }
.proof-row p { overflow-wrap: anywhere; }
.lesson-chart { height: auto; }

@media (max-width: 1024px) {
 .header-inner { gap: 18px; }
 .menu-button { display: block; flex: 0 0 44px; }
 .site-header .site-nav { display: none; position: absolute; inset: 100% 0 auto; padding: 16px 32px 24px; flex-direction: column; align-items: stretch; gap: 4px; font-size: 1rem; max-height: calc(100vh - 100px); max-height: calc(100dvh - 100px); overflow-y: auto; overscroll-behavior: contain; border-bottom: 1px solid #ffffff40; }
 .site-header .site-nav.open { display: flex; }
 .site-header .site-nav a { min-height: 48px; }
 .site-header .site-nav .button { margin-top: 8px; }
 .footer-content { gap: 28px; }
}
@media (max-width: 900px) {
 .hero-grid { grid-template-columns: minmax(0,1fr); gap: 30px; }
 .hero-copy { max-width: 700px; }
 .hero-copy h1 { font-size: clamp(2.75rem,6.2vw,3.75rem); }
 .hero-art { min-height: 340px; max-height: 420px; aspect-ratio: 16/9; }
 .review-grid { grid-template-columns: minmax(0,1fr); gap: 20px; }
 .review-card .review-tag { min-height: 0; }
 .review-card h3 { max-width: 34ch; }
 .review-card cite { padding-top: 20px; }
 .section-head { grid-template-columns: minmax(0,1fr); gap: 20px; }
 .section-head > p:last-child { justify-self: start; max-width: 64ch; }
 .closing-inner { grid-template-columns: minmax(0,1fr); gap: 28px; }
 .closing-actions { align-items: flex-start; }
 .legal-layout { grid-template-columns: minmax(0,1fr); gap: 28px; }
 .legal-sidebar { position: static; max-height: none; overflow: visible; }
 .legal-sidebar ol { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 4px 20px; }
}
@media (max-width: 640px) {
 .site-header .brand { padding-inline: 0; max-width: calc(100% - 62px); }
 .site-header .brand img { width: 189px; height: auto; max-width: 100%; }
 .site-header .site-nav { padding-inline: 18px; }
 .hero-art { aspect-ratio: 4/3; min-height: 290px; }
 .hero-art-top { flex-wrap: wrap; gap: 8px; font-size: .75rem; }
 .hero-art-copy { left: 22px; right: 22px; }
 .hero-art-copy small { font-size: .875rem; line-height: 1.5; }
 .footer-content { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 24px 20px; }
 .footer-meta { align-items: flex-start; }
 .footer-credit { flex-basis: 100%; }
 .footer-legal { margin-left: 0; gap: 24px; }
 .course-top, .plan-heading, .plan-actions { flex-wrap: wrap; }
 .course-top > *, .plan-actions > * { min-width: 0; }
 .lesson-toolbar { gap: 6px 14px; }
 .lesson-controls { gap: 10px; }
 .lesson-controls button { padding-inline: 12px; }
 .course-button { font-size: .875rem; }
 .code-window { font-size: .875rem; }
 .proof-row { grid-template-columns: minmax(0,1fr); gap: 4px; }
 .proof-row small { font-size: .875rem; }
 .crypto-equation { gap: 12px; padding-inline: 12px; }
 .crypto-equation strong { font-size: 2rem; }
 .crypto-result { margin-inline: 12px; padding-inline: 8px; font-size: 1.125rem; overflow-wrap: anywhere; }
 .sort-stage { padding-inline: 12px; }
 .sort-bars { padding-inline: 4px; gap: 6px; }
 .directory-result-bar { gap: 6px 18px; padding-block: 12px; }
 .map-inputs select { font-size: 1rem; }
}
@media (max-width: 420px) {
 .hero-copy h1 { font-size: clamp(2.5rem,11vw,3rem); }
 .hero-art-top { left: 18px; right: 18px; }
 .memory-panel { flex-direction: column; }
 .memory-cell { width: 100%; }
 .course-buttons { grid-template-columns: minmax(0,1fr); }
 .collaboration-tools article { display: block; }
 .collaboration-tools .tool-name { margin-bottom: 12px; }
 .collaboration-tools h3 { margin-bottom: 10px; }
 .legal-sidebar ol { grid-template-columns: minmax(0,1fr); }
 .sort-value { font-size: 1rem; }
 .search-array { gap: 3px; padding-inline: 5px; }
 .array-item { padding-inline: 2px; font-size: .875rem; }
 .instruction-actions .button, .instruction-booking .button { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
 html { scroll-behavior: auto; }
 .sort-bar, .proof-row, .button { transition: none; }
}
