/* Mobile layout: preserve readable widths and prevent header/dashboard/calendar collapse. */
@media (max-width: 700px) {
  .home-head {
    height: auto; min-height: 0; padding: 12px 14px 10px; gap: 10px;
    display: grid; grid-template-columns: minmax(0,1fr) auto;
    grid-template-areas: "brand theme" "skill skill" "auth auth";
    align-items: center; justify-content: stretch;
  }
  .home-head > .brand { grid-area: brand; min-width: 0; }
  .home-head > .brand img { width: clamp(150px, 48vw, 190px); max-width: 100%; max-height: 42px; }
  .home-head > .skill-nav { grid-area: skill; width: 100%; justify-content: stretch; }
  .home-head > .skill-nav .skill-tab { flex: 1 1 0; justify-content: center; min-width: 0; }
  .home-head > #themeToggle { grid-area: theme; position: static; justify-self: end; margin: 0; max-width: 100%; padding: 8px 10px; white-space: nowrap; font-size: 10px; }
  .home-head > .home-auth { grid-area: auth; width: 100%; min-width: 0; margin: 0; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; }
  .home-auth > button, .home-auth > .home-account { min-width: 0; width: 100%; }
  .home-auth > button { min-height: 40px; padding: 8px 5px; font-size: 10px; white-space: normal; }
  .home-account { grid-column: 1 / -1; justify-self: end; width: max-content !important; max-width: 100%; }
  .home-account > .home-account-trigger { width: auto; max-width: 100%; }
  .home-account-menu { right: 0; }

  .learner-dashboard-inner { padding: 14px 16px; gap: 12px; }
  .learner-dashboard h2 { font-size: 18px; white-space: normal; }
  .exam-summary { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); width: 100%; gap: 12px; }
  .exam-summary-item { min-width: 0; text-align: left; overflow-wrap: anywhere; }
  .exam-summary-item:first-child { grid-column: 1 / -1; }
  .exam-summary-item strong { font-size: 14px; }
  .dashboard-edit { grid-column: 1 / -1; justify-self: end; margin-left: 0; }

  main { width: 100%; max-width: 100%; padding-inline: 16px; }
  .welcome {
    display: grid; grid-template-columns: minmax(0,1fr); grid-auto-flow: row;
    gap: 16px; padding: 30px 0 24px; overflow: visible; align-items: stretch;
  }
  .welcome-copy, .streak-card, .welcome-side-stack { grid-column: 1; grid-row: auto; width: 100%; min-width: 0; max-width: none; justify-self: stretch; }
  .welcome-copy { overflow-wrap: normal; word-break: normal; }
  .welcome-copy .eyebrow { font-size: 9px; letter-spacing: 1.6px; }
  .welcome h1 { max-width: 100%; font-size: clamp(34px, 9vw, 46px); line-height: 1.08; letter-spacing: -1.8px; overflow-wrap: normal; word-break: normal; }
  .welcome-copy > p { max-width: 100%; font-size: 13px; line-height: 1.65; }
  .welcome:after { right: -70px; top: 10px; width: 220px; height: 220px; pointer-events: none; }
  .streak-card { padding: 16px 14px 12px; }
  .streak-calendar, .streak-day-labels { width: 100%; grid-template-columns: repeat(7,minmax(0,1fr)); }
  .streak-calendar { grid-template-rows: repeat(var(--streak-weeks,6),minmax(32px,1fr)); grid-auto-columns: auto; gap: 4px; }
  .streak-day { width: 100%; height: auto; min-width: 0; min-height: 0; aspect-ratio: 1; border-radius: 8px; }
  .streak-day-labels { grid-template-rows: none; height: 22px; gap: 4px; }
  .welcome-side-stack { display: grid; gap: 9px; }
  .welcome-side-stack .welcome-aside { width: 100%; max-width: none; margin: 0; }

  .feature-section, .library-section { min-width: 0; }
  .feature-heading { display: grid; gap: 8px; }
  .feature-heading h2 { font-size: 20px; line-height: 1.3; }
  .step-hint { font-size: 9px; line-height: 1.5; }
  .feature-grid { grid-template-columns: minmax(0,1fr); gap: 9px; }
  .feature-card { grid-template-columns: 40px minmax(0,1fr) auto; min-width: 0; min-height: 82px; gap: 10px; padding: 11px; }
  .feature-copy { min-width: 0; }
  .feature-copy > small { font-size: 10px; }
  .feature-select { white-space: normal; text-align: right; }

  .library-heading { display: grid; gap: 12px; align-items: stretch; }
  .library-heading h2 { font-size: 23px; line-height: 1.25; }
  .library-heading > div { min-width: 0; }
  .library-tools { width: 100%; min-width: 0; margin: 0; align-items: stretch; }
  .search-box { width: 100%; min-width: 0; margin: 0; }
  .library-track-switch { align-self: flex-start; }
  .availability-legend { flex-wrap: wrap; line-height: 1.5; }
  .book-grid:not(:has(> .catalog-test-card)) { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
  .book-grid:not(:has(> .catalog-test-card)) .book-card { min-width: 0; padding: 12px; }
  .book-grid:not(:has(> .catalog-test-card)) .test-links { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .book-grid:not(:has(> .catalog-test-card)) .test-link { min-width: 0; min-height: 36px; }
  footer { gap: 10px; line-height: 1.5; }
}
@media (max-width: 620px) {
  .book-grid:has(> .catalog-test-card) { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  .catalog-test-card { aspect-ratio: auto; min-height: 0; min-width: 0; padding: 13px; border-radius: 12px; cursor: pointer; }
  .catalog-test-card:focus-visible { outline: 3px solid #6ca982; outline-offset: 2px; }
  .catalog-test-card-top { gap: 6px; font-size: 9px; letter-spacing: .5px; }
  .catalog-card-mark { flex: 0 0 28px; width: 28px; height: 28px; }
  .catalog-test-card-copy { min-width: 0; margin: 12px 0 auto; padding: 8px 0 13px; }
  .catalog-card-identifier { margin-bottom: 5px; font-size: 19px; letter-spacing: -.5px; }
  .catalog-test-card h3 { font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
  .catalog-test-card-copy p { margin-top: 6px; font-size: 12px; }
  .catalog-status, .catalog-status:not(.is-plus) { margin-top: 8px; padding: 4px 7px; font-size: 9px; }
  .catalog-test-card-bottom { gap: 7px; }
  .catalog-test-card-bottom > span { font-size: 9px; line-height: 1.35; }
  .catalog-test-card-bottom .catalog-start-link { min-height: 36px; padding: 8px; font-size: 10px; }
  .catalog-pagination { flex-wrap: wrap; }
}
@media (max-width: 360px) {
  .book-grid:has(> .catalog-test-card), .book-grid:not(:has(> .catalog-test-card)) { grid-template-columns: minmax(0,1fr); }
  .catalog-test-card { min-height: 166px; }
  .home-head { padding-inline: 12px; }
  main { padding-inline: 12px; }
}
