/* LetsMath mobile layout overrides */
@media (max-width: 760px) {
  :root { font-size: 14px; }
  html, body { max-width: 100%; overflow-x: hidden; }
  button, input, select, textarea { font-size: 16px; }

  .topbar { height: auto; min-height: 112px; align-items: center; flex-wrap: wrap; gap: 8px; padding: 9px 12px; }
  .brand { min-width: 0; flex: 0 0 auto; gap: 7px; }
  .brand .mark { width: 34px; height: 34px; border-radius: 10px; font-size: 20px; }
  .brand b { font-size: 15px; }
  .brand small { font-size: 8px; }
  .tools { margin-left: auto; gap: 6px; flex: 0 0 auto; }
  .tools .tool, .tools .talk-link { display: none; }
  .tools .account { max-width: 108px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .mainnav { order: 3; display: flex; flex: 1 1 100%; width: 100%; height: 42px; min-width: 0; overflow-x: auto; overflow-y: hidden; gap: 20px; padding: 0 2px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .mainnav::-webkit-scrollbar { display: none; }
  .mainnav button, .more button { flex: 0 0 auto; min-height: 40px; padding: 9px 0 11px; font-size: 13px; white-space: nowrap; }
  .more { flex: 0 0 auto; }
  .more-menu { position: fixed; z-index: 40; top: 108px; right: 8px; left: 8px; min-width: 0; max-height: calc(100vh - 124px); overflow-y: auto; }

  .shell { width: 100%; max-width: none; padding: 18px 12px 42px; }
  .headline { display: block; gap: 14px; margin-bottom: 18px; }
  .headline h1 { font-size: 25px; line-height: 1.28; letter-spacing: -1.1px; }
  .headline p { font-size: 13px; line-height: 1.55; }
  .headline .primary, .headline .outline { width: 100%; margin-top: 14px; }
  .panel { padding: 16px; border-radius: 12px; }
  .panelhead { align-items: flex-start; flex-wrap: wrap; gap: 12px; }
  .panelhead > div { min-width: 0; }
  .panelhead .primary, .panelhead .outline { width: 100%; }

  .tabs, .assessment-tabs, .arithmetic-tabs, .textbook-list-tabs, .exam-search-tabs, .talk-tabs { max-width: 100%; overflow-x: auto; white-space: nowrap; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar, .assessment-tabs::-webkit-scrollbar, .arithmetic-tabs::-webkit-scrollbar, .textbook-list-tabs::-webkit-scrollbar, .exam-search-tabs::-webkit-scrollbar, .talk-tabs::-webkit-scrollbar { display: none; }
  .assessment-tabs, .arithmetic-tabs, .exam-search-tabs, .talk-tabs { gap: 20px; }

  .filters, .assessment-toolbar, .textbook-toolbar, .exam-filters { display: grid; grid-template-columns: 1fr; align-items: stretch; gap: 8px; width: 100%; }
  .filters input, .filters select, .filters button, .filters label, .assessment-toolbar select, .textbook-toolbar select, .exam-filters select, .assessment-toolbar > *, .textbook-toolbar > *, .exam-filters > * { width: 100%; min-width: 0; box-sizing: border-box; }
  .filters input { min-width: 0; }

  /* Dense management tables stay readable through an intentional inner scroll. */
  .table, .assessment-table, .exam-table, .arithmetic-answer-table, .account-table, .status-week-grid { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-head, .table-row { min-width: 1000px; }
  .assessment-table-head, .assessment-row { min-width: 1120px; }
  .exam-table-head, .exam-table-row { min-width: 900px; }
  .arithmetic-answer-row { min-width: 620px; }
  .account-table-head, .account-table-row { min-width: 620px; }
  .status-week-grid { grid-template-columns: 220px repeat(var(--status-days), 100px); }
  .status-toolbar { align-items: stretch; flex-direction: column; gap: 8px; }
  .status-toolbar select, .status-search { width: 100%; min-width: 0; box-sizing: border-box; }

  .contentgrid, .statgrid, .feedback-summary-grid, .parent-report-grid, .calendar-layout, .account-page-grid, .account-guide-grid, .academy-detail-content { grid-template-columns: 1fr; }
  .statgrid { gap: 10px; }
  .student-form, .daily-test-form, .parent-event-form, .account-form-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
  .student-form > *, .daily-test-form > *, .parent-event-form > * { min-width: 0; width: 100%; box-sizing: border-box; }
  .student-form button, .daily-test-form button, .parent-event-form button { width: 100%; }
  .textbook-search { width: 100%; box-sizing: border-box; }
  .textbook-search input { width: 100%; min-width: 0; box-sizing: border-box; }

  .progressrow { grid-template-columns: 34px minmax(120px, 1fr) 72px; gap: 9px; }
  .progressrow .progress { grid-column: 2 / -1; }
  .progressrow .outline, .progressrow .primary { grid-column: 1 / -1; width: 100%; }
  .daily-runner-meta, .parent-report-hero { display: block; }
  .daily-runner-meta > *, .parent-report-score { margin-top: 14px; }
  .daily-test-row, .calendar-event { display: block; }
  .daily-test-row .primary { margin-top: 18px; width: 100%; }
  .calendar-event time { display: block; margin-bottom: 8px; }
  .calendar-event .status-pill { margin-top: 12px; }

  .academy-map-toolbar { align-items: stretch; flex-direction: column; gap: 9px; }
  .academy-map-toolbar > *, .academy-map-toolbar button { width: 100%; }
  .map-stage { height: 260px; }
  .academy-detail-content > .panel { padding: 18px; }
  .academy-detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .academy-detail-actions button { width: 100%; }

  .loginbox { width: min(460px, calc(100% - 24px)); padding: 23px 18px; }
  .notice { left: 12px; right: 12px; bottom: 12px; text-align: center; }
}

@media (max-width: 420px) {
  .brand b { font-size: 14px; }
  .brand small { display: none; }
  .tools .account { max-width: 84px; }
  .mainnav { gap: 16px; }
  .shell { padding-right: 10px; padding-left: 10px; }
  .panel { padding: 14px; }
  .headline h1 { font-size: 23px; }
  .academy-detail-actions { grid-template-columns: 1fr; }
}
