/* Phone-only corrections. Desktop rules and theme colors remain in the existing stylesheets. */
@media (max-width: 767px) {
  html { scroll-padding-top: 90px; }
  body { overflow-wrap: anywhere; }
  body .shell, body .split, body .split-main, body .split-aside,
  body main.container, body fieldset { min-width: 0; max-width: 100%; }
  body.has-side, body.ed-textbook.has-side { padding-left: 0; }
  body .container, body.has-side .container, body.ed-textbook .container {
    width: 100%; margin-inline: auto; padding: 20px max(14px, env(safe-area-inset-right)) max(48px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }
  body .split, body .split.left, body .split.pg-lesson { display: block; }
  body .split-aside { position: static; width: 100%; margin-top: 24px; }
  body .topnav, body.has-side .topnav, body.ed-textbook.has-side .topnav {
    padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
    gap: 10px; flex-wrap: wrap; align-items: center;
  }
  body .member-nav { max-height: 90vh; max-height: 90dvh; overflow-y: auto; overscroll-behavior: contain; }
  body .member-nav .brand { min-width: 0; max-width: calc(100% - 100px); }
  body .brand img { max-width: 100%; height: auto; max-height: 44px; object-fit: contain; }
  body .member-nav .nav-toggle { flex: none; min-height: 44px; padding: 8px 10px; font-size: 14px; }
  body .member-nav .topnav-right, body.has-side .member-nav .topnav-right, body.ed-textbook .member-nav .topnav-right {
    width: 100%; flex-basis: 100%; display: grid; grid-template-columns: minmax(0,1fr); gap: 6px;
    overflow: visible; white-space: normal;
  }
  body .member-nav .topnav-right[hidden] { display: none !important; }
  body .member-nav .topnav-right > a { min-height: 46px; margin: 0; padding: 10px 12px; font-size: 15px; white-space: normal; }
  body .sidenav, body .lesson-side { display: none !important; }
  body h1, body .lesson h1, body .course-head h1 { font-size: 24px; line-height: 1.5; overflow-wrap: anywhere; }
  body .learning-card h1, body .learning-card h2, body .room-hero h1 { font-size: 22px; line-height: 1.5; }
  body .hero-lead { font-size: 15px; line-height: 1.8; }
  body input:not([type=checkbox]):not([type=radio]):not([type=hidden]), body textarea, body select {
    font-size: 16px !important; min-width: 0; max-width: 100%; box-sizing: border-box;
  }
  body input:not([type=checkbox]):not([type=radio]):not([type=hidden]), body select { min-height: 46px; }
  body textarea { width: 100%; line-height: 1.7; }
  body .btn, body button:not(.audio-track):not([role=tab]), body summary.btn {
    min-height: 46px; max-width: 100%; white-space: normal; overflow-wrap: anywhere; line-height: 1.6;
  }
  body .btn { padding: 11px 14px; text-align: center; }
  body .auth-card { width: 100%; max-width: 100%; margin: 12px auto 24px; padding: 24px 18px; }
  body .auth-card form, body .auth-card label { min-width: 0; }
  body .auth-links { gap: 4px; }
  body .auth-links a { display: block; padding: 10px 0; font-size: 14px; }
  body .install-guide { text-align: left; padding: 24px 18px; }
  body .install-guide h1 { font-size: 23px; margin-bottom: 16px; }
  body .install-guide h2 { font-size: 19px; margin: 28px 0 12px; padding-top: 18px; border-top: 1px solid var(--line); }
  body .install-guide p { line-height: 1.85; margin-bottom: 14px; }
  body .install-guide ol { padding-left: 1.4em; }
  body .install-guide li { padding-left: 3px; margin-bottom: 14px; line-height: 1.8; }
  body .install-guide > .btn { display: block; width: 100%; margin-top: 22px; }
  body .course-grid, body .lesson-tiles, body .lib-grid, body .lib-cat-grid,
  body .area-grid, body .tools-grid, body .home-areas, body .learning-questions,
  body .learning-areas, body .learning-roadmap, body .learning-progress-grid,
  body .mp-grid, body .stepper, body .home-tools-grid, body .other-rooms,
  body.ed-textbook .area-grid, body.ed-textbook .tools-grid, body.ed-textbook .home-areas,
  body.ed-textbook .lupinus-course-grid, body.ed-textbook .lib-grid,
  body.has-side .lesson-tiles, body.has-side .lib-grid, body.has-side .lib-cat-grid,
  body .member-home .course-grid { grid-template-columns: minmax(0,1fr); }
  body .course-card, body .lesson-tile, body .lib-card, body .home-tool { min-width: 0; }
  body.ed-textbook .lupinus-design-tools li > a, body.ed-textbook .lupinus-feedback-link {
    display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 10px; padding: 14px;
  }
  body.ed-textbook .lupinus-tool-thumb-mini { grid-column: 1 / -1; width: 100%; max-width: 100%; height: auto; }
  body .learning-card, body .onb-card, body .lib-card, body .coach-card, body .mp-card { padding: 20px 16px; }
  body .learning-card-heading { align-items: flex-start; gap: 10px; }
  body .learning-card-heading img { width: 64px; max-width: 25%; height: auto; }
  body .learning-roadmap li { flex-wrap: wrap; padding: 14px 12px; }
  body .learning-roadmap li > div { flex-basis: calc(100% - 50px); }
  body .learning-roadmap li > a { margin-left: 42px; min-height: 44px; display: inline-flex; align-items: center; }
  body .course-toolbar, body.ed-textbook .lupinus-course-toolbar { display: grid; grid-template-columns: minmax(0,1fr); gap: 12px; }
  body .lecture-menu > summary, body .lupinus-index-menu > summary { justify-content: center; min-height: 46px; }
  body .lecture-menu-panel { width: 100%; max-width: 100%; }
  body .lesson, body .lesson-body, body .coach-answer, body .md { min-width: 0; overflow-wrap: anywhere; }
  body .lesson-body img, body .lesson-body video, body .lesson-body iframe, body .player { max-width: 100%; }
  body .lesson-body iframe { width: 100%; }
  body .lesson-nav, body .lesson-step-nav { display: grid; grid-template-columns: minmax(0,1fr); gap: 10px; }
  body .lesson-nav .btn, body .lesson-step-nav a { width: 100%; }
  body .chapter-accordion > summary { font-size: 18px; padding: 16px 14px; }
  body .progress-line { flex-wrap: wrap; }
  body .progress-num { white-space: normal; }
  body .rv-id-form, body .mp-name, body .acct-pick, body .save-bar, body .coach-submit, body .rv-submit { flex-wrap: wrap; }
  body .rv-id-form input, body .mp-name label, body .save-bar-text, body .rv-submit p, body .next-step p, body .start-row p, body .creaca-before span { min-width: 0; max-width: 100%; }
  body .mp-name label { flex-basis: 100%; }
  body .rv-id-form input { flex-basis: 100%; width: 100%; }
  body .rv-kv, body .acct-preview { grid-template-columns: minmax(0,1fr); }
  body .rv-dialog, body dialog { max-width: calc(100vw - 28px); max-height: calc(100dvh - 32px); overflow-y: auto; }
  body .md-table { max-width: 100%; overflow-x: auto; }
  body pre { max-width: 100%; overflow-x: auto; }
  body .audio-player { padding: 18px 14px; margin: 18px 0; }
  body .audio-player h2 { font-size: 19px; line-height: 1.6; }
  body .audio-player audio { width: 100%; min-width: 0; max-width: 100%; }
  body .audio-controls { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  body .audio-controls #audio-play, body .audio-controls #audio-resume, body .audio-controls label { grid-column: 1 / -1; }
  body .audio-controls [hidden] { display: none; }
  body .audio-controls .btn { width: 100%; min-height: 48px; font-size: 15px; }
  body .audio-controls label { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  body .audio-controls select { flex: 1; }
  body .audio-track-list { padding-left: 22px; }
  body .audio-track { display: block; width: 100%; min-height: 48px; padding: 10px 6px; font-size: 16px; }
  body .audio-track-list a { display: inline-flex; align-items: center; min-height: 44px; padding: 6px; }
  body .audio-chapters section { padding: 18px 16px; }
  body .audio-chapters .btn, body .chapter-audio-link .btn { display: block; width: 100%; min-height: 48px; font-size: 16px; }
  body .chapter-audio-link { padding: 12px 14px; }
  body .script-downloads > ul { padding-left: 20px; }
  body .script-downloads > ul > li { padding: 5px 0; }
  body .script-downloads > ul > li > a { display: block; padding: 10px 0; min-height: 46px; }
  body .script-downloads .btn { display: block; width: 100%; min-height: 50px; font-size: 16px; }
  body .foot { padding: 22px 14px max(26px,env(safe-area-inset-bottom)); line-height: 1.8; }
  body .foot a { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 6px; }
}
