/* Current Figma reference: 3:210 and the shared components on the Thành phần page.
   Exact measured values and node references: output/figma-prototype-reference.json.
   This layer changes appearance; application state and persistence stay in app.js. */
/* Shared theme values now come from generated tokens.css. */
body { font-family: 'Baloo Bhaina 2', 'Segoe UI', sans-serif; font-size: 16px; line-height: 24px; }
h1, h2, h3 { letter-spacing: 0; }
h1 { font-size: 28px; line-height: 36px; font-weight: 700; }
h2 { font-size: 18px; line-height: 24px; font-weight: 700; }
h3 { font-size: 16px; line-height: 24px; }
small { font-size: 14px; line-height: 20px; }
.card, .table-frame, .empty-state, .next-lesson { border-radius: var(--radius-card); }
.button, .icon-button, input, select, textarea, .filter-tabs, .theme-option { border-radius: var(--radius-control); }
.button { min-height: 44px; padding: 8px 16px; font-size: 16px; line-height: 24px; font-weight: 600; gap: 8px; }
.button.primary { border: 0; }
.button .icon { width: 20px; height: 20px; }
.field { font-size: 14px; line-height: 20px; gap: 8px; margin-bottom: 16px; }
.field > span { font-weight: 600; }
.lesson-create-card .field { font-size: 14px; line-height: 20px; gap: 8px; margin-bottom: 16px; }
.lesson-create-card .field-help { font-size: 14px; line-height: 20px; }
.lesson-form-section h2 { font-size: 16px; line-height: 24px; }
input:not([type='checkbox']):not([type='radio']), select, textarea {
  font-family: inherit; font-size: 16px; line-height: 24px; border-color: var(--input-line); border-radius: var(--radius-control);
  -webkit-appearance: none; appearance: none; box-sizing: border-box; min-width: 0; max-width: 100%;
}
input:not([type='checkbox']):not([type='radio']), select { height: 48px; min-height: 48px; padding: 11px 12px; }
.field:has(> select) { position: relative; --select-height: 48px; }
.field > select { padding-right: 40px; }
.page-settings .field > select { padding-right: 40px; }
.field:has(> select)::after {
  content: ''; position: absolute; width: 16px; height: 16px; right: 12px; bottom: calc((var(--select-height) - 16px) / 2);
  pointer-events: none; background: var(--muted);
  -webkit-mask: url('../assets/chevron-down.svg') center / 16px 16px no-repeat;
  mask: url('../assets/chevron-down.svg') center / 16px 16px no-repeat;
}
textarea { min-height: 112px; padding: 12px; }
/* iOS's native temporal control can override border-box sizing and overflow padded forms.
   appearance:none keeps the date/time picker while letting our CSS own the control box.
   WebKit issue: https://bugs.webkit.org/show_bug.cgi?id=301648 */
input:is([type='date'], [type='time'], [type='datetime-local'], [type='month'], [type='week']) {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  box-sizing: border-box;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}
input::-webkit-date-and-time-value { min-height: 24px; text-align: left; }
:is(.field, .search-box) :is(input, textarea)::placeholder { font-size: 16px; line-height: 24px; color: var(--muted); }
.search-box { margin-bottom: 16px; }
.search-box input:not([type='checkbox']):not([type='radio']) { display: block; min-height: 52px; padding: 13px 12px 13px 40px; border-color: var(--input-line); }
.search-box > .icon { width: 20px; height: 20px; top: 16px; left: 12px; }
.field-help, .form-error, .notice p, .report-footnote { font-size: 14px; line-height: 20px; }
.empty-state { padding: 32px 24px; border: 1px solid var(--line); }
.empty-state h3 { font-size: 16px; line-height: 24px; font-weight: 600; }
.empty-state p { font-size: 16px; line-height: 24px; }
.detail-toolbar h1 { font-size: 24px; line-height: 32px; }
.detail-card { padding: 16px; }
.filter-tabs button { font-size: 14px; line-height: 20px; }
.page-settings .detail-card h2 { font-size: 16px; line-height: 24px; }
.page-settings .detail-card p, .page-settings .notice p { font-size: 16px; line-height: 24px; }
.page-settings .detail-card { padding: 16px; }
.page-settings .settings-data { margin-top: 16px; }
.page-settings .settings-grid > div:first-child, .page-settings .settings-data { gap: 16px; }
.page-settings .theme-option, .page-settings .system-theme { border-radius: var(--radius-control); }
.page-settings .system-theme { min-height: 44px; font-size: 16px; line-height: 24px; padding: 8px 16px; }
.page-settings .theme-option > span:last-child, .page-settings .field { font-size: 16px; line-height: 24px; }
.page-settings .theme-help { font-size: 14px; line-height: 20px; }
.page-reports .report-filters { padding: 16px; gap: 16px; border-radius: var(--radius-card); }
.page-reports .report-filters :is(input, select) { min-height: 48px; font-size: 16px; line-height: 24px; padding: 11px 12px; }
.page-reports .report-filters .field { font-size: 14px; line-height: 20px; }
.page-reports .report-filters .apply-report { min-height: 44px; font-size: 16px; line-height: 24px; padding: 8px 16px; }
.page-reports .report-stats .stat-card { min-height: 78px; padding: 12px; }
.page-reports .report-stats .stat-card > span { min-height: 0; font-size: 14px; line-height: 20px; }
.page-reports .report-stats .stat-card > strong { font-size: 24px; line-height: 32px; margin: 0; }
.page-reports .report-mobile-card { padding: 16px; }
.page-reports .report-card-person strong { font-size: 16px; line-height: 24px; }
.page-reports .report-card-counts dt { font-size: 14px; line-height: 20px; }
.page-reports .report-card-counts dd { font-size: 24px; line-height: 32px; }
.page-reports .report-card-total, .page-reports .report-card-rate small { font-size: 14px; line-height: 20px; }
.page-reports .report-expiry-row { font-size: 16px; line-height: 24px; padding: 12px 16px; }
.page-reports .report-expiry-row > .grow { font-size: 16px; line-height: 24px; }
.page-reports .report-filter-status { font-size: 14px; line-height: 20px; }
.page-attendance .attendance-class-name { font-size: 18px; line-height: 24px; }
.page-attendance .attendance-metadata > div { font-size: 16px; line-height: 24px; }
.page-attendance .attendance-person-name h3 { font-size: 16px; line-height: 24px; }
.page-attendance .attendance-roster { border-radius: var(--radius-card); }
.page-attendance .attendance-entry .status-option > span { min-height: 44px; font-size: 14px; line-height: 20px; border-radius: var(--radius-control); }
.page-attendance .attendance-search-row .search-box input { min-height: 52px; font-size: 16px; line-height: 24px; }
.page-attendance .attendance-search-row .search-box > .icon { top: 16px; }
.page-attendance .attendance-search-row .attendance-mark-all { font-size: 16px; line-height: 24px; border-radius: var(--radius-control); }
.page-attendance .attendance-save-bar .button { min-height: 44px; font-size: 16px; line-height: 24px; }
.page-attendance .attendance-mark-all { background: var(--green); color: var(--on-primary); }
.count-badge.purple, .avatar:is(.color-0, .color-1, .color-2) { color: var(--primary-ink); }
.page-expiring .filter-tabs button.active { background: var(--primary-soft); color: var(--primary-ink); }
:root[data-theme='dark'] .filter-tabs button.active { background: var(--primary-soft); color: var(--primary-ink); }
.page-home .next-lesson { padding: 16px; }
.page-home .next-lesson .home-lesson-time { font-size: 24px; line-height: 32px; }
.page-home .next-lesson .home-lesson-title { font-size: 16px; line-height: 24px; }
.page-home .next-lesson .home-lesson-context { font-size: 16px; line-height: 24px; }
.page-home .home-attendance-progress > div { font-size: 14px; line-height: 20px; }
.page-home .home-attendance-action { min-height: 44px; font-size: 16px; line-height: 24px; }
.page-home .expiry-widget h2 { font-size: 16px; line-height: 24px; }
.page-home .expiry-line { font-size: 16px; line-height: 24px; }
.page-home .expiry-line > span { font-size: 14px; line-height: 20px; }
.page-home .expiry-widget .button { min-height: 44px; font-size: 16px; line-height: 24px; }

@media (width < 1024px) {
  .topbar { height: calc(61px + env(safe-area-inset-top)); min-height: calc(61px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 16px 0; }
  main, .page-home, .page-calendar, .page-students, .page-reports, .page-settings, .page-attendance, .page-student, .page-lesson-new { padding-top: 16px; padding-inline: 16px; min-height: calc(100dvh - 61px - env(safe-area-inset-top)); }
  :is(.page-home, .page-calendar, .page-students, .page-reports, .page-settings) .page-heading { align-items: flex-end; gap: 16px; margin-bottom: 16px; }
  :is(.page-home, .page-calendar, .page-students, .page-reports, .page-settings) .page-heading h1 { font-size: 24px; line-height: 32px; margin: 0 0 2px; }
  :is(.page-home, .page-calendar, .page-students, .page-reports, .page-settings) .page-heading p { font-size: 16px; line-height: 24px; margin: 0; }
  :is(.page-calendar, .page-students, .page-reports) .page-heading .compact { min-height: 44px; padding: 8px 16px; font-size: 16px; line-height: 24px; }
  :is(.page-calendar, .page-students, .page-reports) .page-heading .compact .icon { width: 20px; height: 20px; }
  .page-students .page-heading { min-height: 58px; }
  .page-students .page-heading .button { min-width: 162px; }
  .page-students .search-box { margin-bottom: 16px; }
  .page-students .search-box input { height: 52px; min-height: 52px; border-color: var(--input-line); font-size: 16px; line-height: 24px; }
  .page-students .filter-tabs { padding: 4px; gap: 4px; margin-bottom: 16px; min-height: 50px; }
  /* The reference has 40px tabs inside a 50px frame with 4px padding. */
  .page-students .filter-tabs button { min-height: 40px; padding: 8px 4px; font-size: 16px; line-height: 24px; }
  .page-students .list-summary { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
  .page-students .table-person strong { font-size: 16px; line-height: 24px; }
  .page-students .student-table tr { padding: 16px; gap: 4px 12px; }
  .page-students .student-code { font-size: 14px; line-height: 20px; }
  .page-students .student-balance { font-size: 16px; line-height: 24px; }
  .page-students .student-package-status .badge { font-size: 14px; line-height: 20px; }
  .page-students .student-results > .empty-state { min-height: 214px; padding: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
  .page-students .empty-state .empty-icon { width: 40px; height: 40px; margin: 0 0 12px; border-radius: 0; background: transparent; color: var(--muted); }
  .page-students .empty-state .empty-icon .icon { width: 36px; height: 36px; }
  .page-students .empty-state h3 { margin: 0 0 8px; }
  .page-students .empty-state p { max-width: 280px; }
  .page-calendar .week-panel { padding: 12px; }
  .page-calendar .week-heading { margin-bottom: 12px; }
  .page-calendar .week-heading h2 { font-size: 16px; line-height: 24px; }
  .page-calendar .week-days { gap: 4px; padding: 0; }
  .page-calendar .day { border-radius: var(--radius-control); background: var(--subtle-surface); }
  .page-calendar .day.selected { background: var(--primary); }
  .page-calendar .timeline-row { padding: 16px 0; }
  .page-calendar .timeline-row strong { font-size: 16px; line-height: 24px; }
  .page-calendar .timeline-row .grow > small { font-size: 14px; line-height: 20px; }
  .page-calendar .section-heading h2 { font-size: 16px; line-height: 24px; }
  .page-reports .report-filters { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
  .page-reports .report-filters .field { font-size: 14px; line-height: 20px; }
  .page-reports .report-filters :is(input, select) { min-height: 48px; font-size: 16px; line-height: 24px; border-color: var(--input-line); }
  .page-reports .report-filters .apply-report { min-height: 44px; font-size: 16px; line-height: 24px; }
  .page-reports .report-stats { gap: 8px; }
  .page-reports .report-stats .stat-card { min-height: 78px; padding: 12px; }
  .page-reports .report-stats .stat-card > span { font-size: 14px; line-height: 20px; min-height: 0; }
  .page-reports .report-stats .stat-card > strong { font-size: 24px; line-height: 32px; }
  .page-reports .report-expiry-row > :is(.subtle, .badge) { font-size: 14px; line-height: 20px; }
  .page-settings .settings-data { margin-top: 16px; }
  .page-settings [data-backup] { min-height: 44px; font-size: 16px; line-height: 24px; }
  .page-home .home-schedule, .page-home .expiry-widget, .page-home .quick-links { margin-top: 16px; }
  .page-home .section-heading h2 { font-size: 16px; line-height: 24px; }
  .page-home .home-schedule h2 { height: auto; }
  .page-home .lesson-row { padding: 16px 12px; border-radius: var(--radius-card); }
  .page-home .lesson-row strong { font-size: 16px; line-height: 24px; }
  .page-home .lesson-row small { font-size: 14px; line-height: 20px; }
  .bottom-nav { min-height: calc(69px + env(safe-area-inset-bottom)); }
  .bottom-nav .nav-item { font-size: 12px; line-height: 16px; }
  .bottom-nav .nav-symbol { border-radius: var(--radius-control); }
}

/* Per-screen refinements from the complete 390px frame exports.
   Main frames: Home 3:32, Calendar 3:107, Attendance 5:341,
   Reports 3:284, Settings 3:418. Populated Home variant: 127:660. */
@media (width < 1024px) {
  .bottom-nav { height: calc(69px + env(safe-area-inset-bottom)); padding: 0 0 env(safe-area-inset-bottom); }
  .topbar .brand strong { font-size: 16px; line-height: 24px; }
  .bottom-nav .nav-item { min-height: 68px; height: 68px; padding: 0; gap: 2px; font-size: 14px; line-height: 20px; font-weight: 400; }
  .bottom-nav .nav-symbol { width: 56px; height: 32px; padding: 0; border-radius: 100px; }
  .bottom-nav .icon { width: 24px; height: 24px; }

  :is(.page-home, .page-calendar) .page-heading { position: relative; display: block; height: 68px; min-height: 68px; margin-bottom: 8px; }
  :is(.page-home, .page-calendar) .page-heading > div { position: relative; width: 100%; height: 68px; }
  :is(.page-home, .page-calendar) .page-heading h1 { position: absolute; left: 0; top: 3px; font-size: 30px; line-height: 60px; margin: 0; }
  :is(.page-home, .page-calendar) .page-heading p { position: absolute; left: 0; top: 40px; font-size: 14px; line-height: 28px; margin: 0; white-space: nowrap; }
  .page-home:has(.next-lesson) .page-heading, .page-home:has(.next-lesson) .page-heading > div { height: 61px; min-height: 61px; }
  .page-home:has(.next-lesson) .page-heading { margin-bottom: 9px; }
  .page-home:has(.next-lesson) .page-heading h1 { top: 0; font-size: 26px; line-height: 52px; }
  .page-home:has(.next-lesson) .page-heading p { top: 37px; font-size: 12px; line-height: 24px; }
  .page-home .next-lesson { display: block; min-height: 196px; padding: 18px 16px 20px; }
  .page-home .home-lesson-eyebrow { min-height: 22px; font-size: 11px; line-height: 22px; font-weight: 700; gap: 8px; flex-wrap: nowrap; }
  .page-home .next-lesson .home-lesson-time { font-size: 24px; line-height: 48px; margin: -3px 0 0; }
  .page-home .next-lesson .home-lesson-title { font-size: 15px; line-height: 30px; margin: -14px 0 0; }
  .page-home .home-lesson-context, .page-home .home-attendance-progress progress, .page-home .home-lesson-status {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap;
  }
  .page-home .home-attendance-progress { margin: -3px 0 0; }
  .page-home .home-attendance-progress > div { min-height: 24px; font-size: 12px; line-height: 24px; }
  .page-home .home-attendance-progress strong { font-weight: 400; }
  .page-home .home-attendance-action { width: 100%; min-height: 46px; margin-top: 8px; padding: 5px 12px; font-size: 18px; line-height: 36px; font-weight: 700; }
  .page-home .home-schedule { margin-top: 26px; }
  .page-home:not(:has(.next-lesson)) .home-schedule .section-heading { margin-bottom: -2px; }
  .page-home:not(:has(.next-lesson)) .home-schedule .lesson-list > .subtle { display: flex; align-items: center; min-height: 68px; padding: 12px; border: 1px solid var(--line); border-radius: 16px; }
  .page-home:has(.next-lesson) .home-schedule { margin-top: 20px; }
  .page-home .home-schedule .section-heading { margin: 0; }
  .page-home .home-schedule h2 { font-size: 17px; line-height: 34px; margin: 0; }
  .page-home:has(.next-lesson) .home-schedule h2 { font-size: 16px; line-height: 32px; }
  .page-home .lesson-row { min-height: 83px; padding: 15px 12px 16px; gap: 16px; }
  .page-home .time-tile { width: 66px; height: 50px; font-size: 16px; line-height: 32px; }
  .page-home .lesson-row strong { font-size: 15px; line-height: 30px; font-weight: 700; }
  .page-home .lesson-row small:not(.home-lesson-status) { margin-top: -3px; font-size: 11px; line-height: 22px; }
  .page-home .expiry-widget { display: grid !important; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 16px; min-height: 178px; margin-top: 24px; }
  .page-home .expiry-widget .section-heading { margin: 0 0 4px; min-height: 28px; gap: 8px; }
  .page-home .expiry-widget h2 { font-size: 18px; line-height: 28px; }
  .page-home .expiry-widget .count-badge { min-width: 24px; height: 20px; padding: 0 8px; font-size: 14px; line-height: 20px; }
  .page-home .expiry-line { min-height: 20px; margin: 0; font-size: 15px; line-height: 20px; }
  .page-home .expiry-line:last-of-type { margin-bottom: 4px; }
  .page-home .expiry-line a { min-height: 20px; line-height: 20px; font-weight: 700; }
  .page-home .expiry-line > span { font-size: 14px; line-height: 20px; font-weight: 700; }
  .page-home .expiry-widget .button { min-height: 44px; margin: 0; font-size: 16px; line-height: 24px; color: var(--ink); border-color: var(--input-line); }
  .page-home:has(.next-lesson) .expiry-widget { display: block !important; min-height: 126px; margin-top: 23px; padding: 10px 14px 11px; }
  .page-home:has(.next-lesson) .expiry-widget .section-heading { min-height: 30px; margin: 0; }
  .page-home:has(.next-lesson) .expiry-widget h2 { font-size: 15px; line-height: 30px; }
  .page-home:has(.next-lesson) .expiry-widget .count-badge { font-size: 13px; line-height: 26px; height: 26px; }
  /* Keep adjacent student links separate; the reference's negative margins overlap hit areas. */
  .page-home:has(.next-lesson) .expiry-line { min-height: 24px; margin: 0; font-size: 12px; line-height: 24px; }
  .page-home:has(.next-lesson) .expiry-line a { min-height: 24px; line-height: 24px; }
  .page-home:has(.next-lesson) .expiry-line > span { font-size: 11px; line-height: 22px; }
  .page-home:has(.next-lesson) .expiry-widget .button { min-height: 30px; height: 30px; margin-top: 1px; padding: 3px 10px; font-size: 11px; line-height: 22px; }
  .home-empty-card { padding: 16px 16px 12px; min-height: 170px; border-radius: 16px; background: var(--primary-soft); }
  .home-empty-icon { display: grid; place-items: center; width: 36px; height: 36px; background: var(--surface); border-radius: 12px; color: var(--primary-ink); }
  .home-empty-card h2 { margin-top: 12px; font-size: 18px; line-height: 36px; }
  .home-empty-card p { margin-top: -4px; font-size: 14px; line-height: 28px; color: var(--muted); }
  .home-empty-card .button { width: 147px; min-height: 36px; height: 36px; margin-top: -2px; padding: 1px 12px; font-size: 16px; line-height: 32px; font-weight: 700; color: var(--primary-ink); background: var(--surface); }
  .home-empty-card .button .icon { width: 16px; height: 16px; }
  :is(.page-home, .page-calendar, .page-attendance, .page-settings) .card { box-shadow: none; }

  .page-calendar .page-heading .compact { position: absolute; right: 0; top: 4px; width: 131px; min-height: 42px; height: 42px; padding: 0 12px; gap: 8px; font-size: 15px; line-height: 30px; }
  .page-calendar .page-heading .compact .icon { width: 14px; height: 14px; }
  .page-calendar .week-panel { padding: 11px 13px 15px; }
  .page-calendar .week-heading { min-height: 35px; flex-wrap: nowrap; gap: 0; margin-bottom: 11px; }
  .page-calendar .week-heading h2 { position: relative; top: 3px; font-size: 15px; line-height: 30px; }
  .page-calendar .week-actions { gap: 8px; }
  .page-calendar .week-actions .icon-button { min-width: 35px; width: 35px; min-height: 35px; height: 35px; border-radius: 12px; }
  .page-calendar .week-actions .icon { width: 16px; height: 16px; }
  .page-calendar [data-week='-1'] .icon { transform: rotate(180deg); }
  .page-calendar .week-today { width: 87px; min-height: 35px; height: 35px; display: inline-flex; align-items: center; justify-content: center; padding: 0 12px; font-size: 13px; line-height: 26px; font-weight: 700; }
  .page-calendar .week-days { width: calc(100% + 8px); margin-inline: -4px; gap: 5px; padding: 0; }
  .page-calendar .day { min-height: 94px; height: 94px; padding: 5px 0; }
  .page-calendar .day > span { position: relative; top: 5px; font-size: 12px; line-height: 24px; font-weight: 700; color: var(--muted); }
  .page-calendar .day strong { position: relative; top: 2px; font-size: 19px; line-height: 38px; }
  .page-calendar .day small { position: relative; top: -2px; font-size: 10px; line-height: 20px; font-weight: 700; color: var(--muted); }
  .page-calendar .day.selected > span, .page-calendar .day.selected small { color: inherit; }
  .page-calendar .day:focus-visible { outline-color: var(--primary-ink); }
  .page-calendar > .section { margin-top: 25px; }
  .page-calendar > .section > .section-heading { margin-bottom: 0; }
  .page-calendar > .section > .section-heading h2 { font-size: 17px; line-height: 34px; }
  .page-calendar > .section > .section-heading .subtle { font-size: 12px; line-height: 24px; font-weight: 700; }
  .page-calendar .timeline-row strong { font-size: 15px; line-height: 30px; font-weight: 700; }
  .page-calendar .timeline-row .grow > small { font-size: 12px; line-height: 24px; margin-top: -3px; }
  .calendar-empty { display: flex; align-items: flex-start; gap: 12px; min-height: 112px; padding: 22px 14px; text-align: left; }
  .calendar-empty-icon { display: grid; place-items: center; flex-shrink: 0; width: 38px; height: 38px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); }
  .calendar-empty > div { position: relative; top: 3px; min-width: 0; }
  .calendar-empty h3 { font-size: 15px; line-height: 30px; font-weight: 700; margin: 0; }
  .calendar-empty p { font-size: 12px; line-height: 24px; margin-top: -3px; }

  .page-attendance .detail-toolbar { height: 44px; min-height: 44px; margin-bottom: 12px; }
  .page-attendance .attendance-summary { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 16px; min-height: 154px; margin-bottom: 12px; }
  .page-attendance .attendance-class-name { max-width: calc(100% - 60px); min-height: 24px; margin: 0; padding: 2px 8px; border-radius: 99px; background: var(--subtle-surface); color: var(--muted); font-size: 14px; line-height: 20px; font-weight: 500; }
  .page-attendance .attendance-metadata { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; width: 100%; }
  .page-attendance .attendance-metadata > div { min-height: 24px; gap: 8px; }
  .page-attendance .attendance-metadata .icon { width: 20px; height: 20px; }
  .page-attendance #attendance-form { display: flex; flex-direction: column; gap: 12px; }
  .page-attendance .attendance-search-row { height: 52px; align-items: center; gap: 8px; }
  .page-attendance .attendance-search-row .search-box { margin: 0; }
  .page-attendance .attendance-search-row .attendance-mark-all { width: 102px; min-width: 102px; min-height: 44px; height: 44px; padding: 8px 16px; gap: 8px; background: var(--green); color: var(--on-primary); border: 0; }
  .page-attendance .attendance-mark-all .icon { width: 20px; height: 20px; }
  .page-attendance .attendance-mark-all > span { flex-shrink: 0; white-space: nowrap; font-weight: 600; }
  .page-attendance .attendance-bulk-help { margin: 0; font-size: 14px; line-height: 20px; }
  .page-attendance .attendance-tabs { min-height: 54px; margin: 0; padding: 4px; gap: 4px; }
  .page-attendance .attendance-tabs button { min-height: 44px; padding: 0; font-size: 16px; line-height: 20px; font-weight: 500; white-space: nowrap; border-radius: 8px; }
  .page-attendance .attendance-tabs button.active { font-weight: 600; }
  .page-attendance .attendance-tabs button:focus-visible { outline-color: var(--primary-ink); }
  .page-attendance .attendance-tabs button:last-child { flex: 0 0 auto; min-width: 116px; }
  .page-attendance .attendance-roster { padding: 0 14px; }
  .page-attendance .attendance-entry { min-height: 118.6667px; padding: 12px 0; }
  .page-attendance .attendance-person-name h3 { position: relative; top: 4px; font-size: 15px; line-height: 30px; font-weight: 700; }
  .page-attendance .attendance-entry .status-options { margin-top: 6px; gap: 8px; }
  .page-attendance .attendance-entry .status-option > span { min-height: 44px; font-size: 16px; line-height: 32px; font-weight: 700; padding: 5px 2px; }
  .page-attendance .attendance-entry .status-option.pending > span { color: var(--muted); }
  .page-attendance .attendance-entry .status-option.selected.pending > span { color: var(--muted); background: var(--subtle-surface); border-color: var(--line); }
  .page-attendance .attendance-session-note { margin: 0; }
  .page-attendance .attendance-save-bar { min-height: 66px; padding: 8px 16px; gap: 8px; border: 1px solid var(--line); }
  .page-attendance .attendance-save-bar .button { flex-shrink: 0; width: 137px; min-width: 137px; height: 48px; min-height: 48px; }
  .page-attendance .attendance-save-feedback > span { font-size: 14px; line-height: 20px; color: var(--muted); }
  .page-attendance .attendance-save-feedback small { font-size: 12px; line-height: 16px; }
  .attendance-progress-details { position: absolute; top: 6px; right: 8px; z-index: 28; }
  .attendance-progress-details > summary { display: flex; align-items: center; justify-content: center; gap: 4px; min-width: 52px; height: 44px; list-style: none; color: var(--primary-ink); font-size: 14px; line-height: 20px; cursor: pointer; border-radius: 12px; }
  .attendance-progress-details > summary .icon { width: 14px; height: 14px; }
  .attendance-progress-details .attendance-overview { position: absolute; top: 44px; right: 0; width: min(300px, calc(100vw - 64px)); padding: 16px; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 2px 8px #0f172a0a, 0 1px 2px #0f172a0f; }

  :is(.page-reports, .page-settings) .page-heading h1 { margin-bottom: 0; }
  .page-reports .page-heading { height: 44px; min-height: 44px; margin-bottom: 16px; }
  .page-reports [data-export] { width: 126px; min-width: 126px; height: 44px; border-color: var(--input-line); }
  .page-reports .report-filters { gap: 12px; margin-bottom: 16px; }
  .page-reports .card, .page-reports .empty-state { box-shadow: var(--frame-shadow); }
  .page-reports .report-filters .field { gap: 6px; font-size: 16px; line-height: 24px; }
  .page-reports .report-filters .field > span { display: flex; align-items: center; gap: 4px; height: 24px; font-size: 16px; line-height: 24px; font-weight: 500; }
  .page-reports .report-filters :is(input, select) { height: 48px; min-height: 48px; padding: 8px 12px; }
  .page-reports .field .required-mark { color: var(--red); }
  .page-reports .report-filters .field-optional { font-size: 14px; line-height: 20px; }
  .page-reports .apply-report { min-height: 44px; margin-bottom: 12px; }
  .page-reports .apply-report[hidden] { display: none; }
  .page-reports .report-apply-actions { margin: 0; }
  .page-reports .report-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
  .page-reports .report-stats-empty { padding-bottom: 8px; }
  .page-reports .report-stats .stat-card { min-height: 78px; padding: 12px; }
  .page-reports .report-stats .stat-card > span { font-weight: 400; }
  .page-reports .report-stats .stat-card.absent > strong { color: var(--orange); }
  .page-reports .empty-state { display: flex; flex-direction: column; align-items: center; padding: 40px 24px; min-height: 302px; }
  .page-reports .empty-state .empty-icon { width: 40px; height: 40px; margin: 0 0 12px; background: none; color: var(--muted); border-radius: 0; }
  .page-reports .empty-state .empty-icon .icon { width: 40px; height: 40px; }
  .page-reports .empty-state h3 { font-size: 18px; line-height: 28px; font-weight: 600; margin: 0 0 4px; }
  .page-reports .empty-state p { font-size: 16px; line-height: 24px; margin: 0; }
  .page-reports .empty-state .button { min-width: 107px; height: 44px; margin-top: 16px; color: var(--ink); border-color: var(--input-line); }

  .page-settings .page-heading { height: 32px; min-height: 32px; margin-bottom: 16px; }
  .page-settings .language-card { min-height: 110px; padding: 12px 16px 16px; }
  .page-settings .language-card h2, .page-settings .theme-card h2 { font-size: 18px; line-height: 36px; margin: 0; }
  .page-settings .language-card .field { gap: 0; }
  .page-settings .language-card .field { --select-height: 44px; }
  .page-settings .language-card select { height: 44px; min-height: 44px; font-size: 16px; line-height: 30px; padding: 6px 40px 6px 12px; }
  .page-settings .theme-card { min-height: 172px; padding: 12px 16px 16px; }
  .page-settings .theme-card h2 { margin-bottom: 2px; }
  .page-settings .theme-options { gap: 12px; }
  .page-settings .theme-option { height: 104px; padding: 7px; border-color: var(--input-line); }
  .page-settings .theme-option.selected { padding: 6px; border: 2px solid var(--primary); box-shadow: none; }
  .page-settings .theme-preview { height: 50px; padding: 5px; gap: 8px; background: var(--subtle-surface); }
  .page-settings .theme-preview > i { display: block; flex-shrink: 0; width: 20%; padding: 4px 5px; background: #dadde1; }
  .page-settings .theme-preview > i b { height: 3px; margin: 0; width: 12px; background: #dadde1; }
  .page-settings .theme-preview > i b:first-child { background: #0866ff; }
  .page-settings .theme-preview > i b:nth-child(2) { margin-top: 7px; width: 14px; }
  .page-settings .theme-preview > i b:last-child { margin-top: 3px; width: 10px; height: 1px; }
  .page-settings .theme-preview > span { display: block; padding-top: 5px; }
  .page-settings .theme-preview > span b { height: 3px; width: 73%; margin: 0 0 3px; background: #dadde1; }
  .page-settings .theme-preview > span b:first-child { width: 45%; height: 4px; margin-bottom: 6px; background: #64748b; }
  .page-settings .theme-preview > span b:nth-child(3) { width: 55%; margin-bottom: 6px; }
  .page-settings .theme-preview > span b:last-child { width: 32%; height: 6px; margin: 0; background: #0866ff; }
  .page-settings .theme-preview.dark { background: #172235; }
  .page-settings .theme-preview.dark > i { background: #233348; }
  .page-settings .theme-preview.dark > i b { background: #606770; }
  .page-settings .theme-preview.dark > i b:first-child { background: #98cfff; }
  .page-settings .theme-preview.dark > span b { background: #606770; }
  .page-settings .theme-preview.dark > span b:first-child { background: #a5b4cb; }
  .page-settings .theme-preview.dark > span b:last-child { background: #98cfff; }
  .page-settings .theme-option > span:last-child { margin-top: 6px; font-size: 15px; line-height: 30px; font-weight: 700; }
  .page-settings .theme-system-setting .system-theme { margin-top: 0; }
}

@media (width < 1024px) {
  :root:not([data-theme='dark']) .page-home:has(.next-lesson) .page-heading h1,
  :root:not([data-theme='dark']) .page-home .next-lesson,
  :root:not([data-theme='dark']) .page-home .next-lesson .home-lesson-time { color: var(--swim-home-text); }
  :root:not([data-theme='dark']) .page-home:has(.next-lesson) .page-heading p { color: var(--swim-home-muted); }
  :root:not([data-theme='dark']) .page-home .next-lesson { background: var(--swim-home-surface); }
  :root:not([data-theme='dark']) .page-home .home-lesson-eyebrow { color: var(--swim-home-label); }
  :root:not([data-theme='dark']) .page-home .home-attendance-progress { color: var(--swim-home-muted); }
  :root:not([data-theme='dark']) .page-home .time-tile { background: var(--swim-home-time); }
  :root:not([data-theme='dark']) .page-calendar .day.selected, :root:not([data-theme='dark']) .page-calendar .day.selected:hover { background: var(--swim-color-selected); border-color: var(--swim-color-selected); color: var(--swim-color-on-selected); }
  :root:not([data-theme='dark']) .page-attendance .attendance-tabs button.active { background: var(--swim-color-selected); color: var(--swim-color-on-selected); }
  :root:not([data-theme='dark']) .page-attendance .status-option.present > span { color: var(--swim-presence-text); }
  :root:not([data-theme='dark']) .page-attendance .status-option.selected.present > span { background: var(--green-soft); border-color: var(--swim-presence-border); }
  :root:not([data-theme='dark']) .page-attendance .status-option.absent > span { color: var(--swim-absence-text); }
  :root:not([data-theme='dark']) .page-attendance .status-option.selected.absent > span { background: var(--swim-absence-fill); border-color: var(--swim-absence-border); color: var(--swim-white); }
}

/* Supporting application screens keep the frame structure, with readable phone text. */
@media (width < 1024px) {
  :is(.page-lesson, .page-summary, .page-student-new, .page-student-edit, .page-expiring) .back-link { font-size: 14px; line-height: 20px; }
  :is(.page-lesson, .page-summary, .page-student-new, .page-student-edit, .page-expiring) .page-heading p { font-size: 14px; line-height: 20px; margin-top: 4px; }
  .page-lesson .detail-list, .page-lesson .detail-card > p { font-size: 14px; line-height: 22px; }
  :is(.page-lesson, .page-summary) .person-row strong { font-size: 16px; line-height: 24px; }
  :is(.page-lesson, .page-summary) .person-row small,
  :is(.page-lesson, .page-summary) .badge { font-size: 12px; line-height: 20px; }
  .page-summary .success-banner p, .page-summary .summary-note { font-size: 14px; line-height: 22px; }
  .page-summary .stat-grid.three .stat-card > span { display: block; min-height: 40px; font-size: 14px; line-height: 20px; }
  .identity-meta .badge, .profile-history .badge,
  .profile-history .history-row small, .profile-package-content > p,
  .package-title .badge, .package-metrics span { font-size: 12px; line-height: 20px; }
  .profile-history .history-row strong { font-size: 14px; line-height: 22px; }
  .profile-facts > div, .profile-contact > summary, .profile-contact > div,
  .profile-notes > summary { font-size: 14px; line-height: 22px; }
  .profile-contact > div { flex-wrap: wrap; }
  .profile-contact > div > a { display: inline-flex; align-items: center; min-height: 44px; }
  .profile-package .package-edit { font-size: 14px; padding-inline: 10px; }
  .profile-package .package-title { font-size: 14px; line-height: 22px; }
  .profile-package .package-metrics > div:last-child strong { color: var(--primary-ink); }
  .repeat-checkbox, .roster-disclosure { font-size: 14px; line-height: 22px; }
  .lesson-create-card .checkbox-person strong { font-size: 14px; line-height: 22px; }
  .lesson-create-card .checkbox-person small, .lesson-create-card .field-optional,
  .roster-remaining, .roster-count { font-size: 12px; line-height: 20px; }
  .roster-search-row .button { font-size: 14px; }
  .student-note-field .field > span { font-size: 14px; }
  .attendance-extra { font-size: 12px; line-height: 20px; }
  .attendance-extra .text-link { font-size: 14px; }
  .page-expiring .expiry-card h3 { font-size: 16px; line-height: 24px; }
  .page-expiring .expiry-card small { font-size: 12px; line-height: 20px; }
  .page-expiring .balance-badge { font-size: 12px; line-height: 20px; }
  .page-expiring .balance-label, .page-expiring .balance-label strong,
  .page-expiring .profile-link { font-size: 14px; line-height: 22px; }
  .form-card .two-col { align-items: end; }
  .form-card .form-actions .button { padding-inline: 10px; gap: 6px; white-space: nowrap; }
}
@media (max-width: 360px) {
  .form-card .form-actions { flex-direction: column-reverse; }
  .form-card .form-actions .button { width: 100%; }
}

/* Keep edge controls outside the sensor housing when the phone rotates. */
@media (width < 1024px) {
  .topbar { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .bottom-nav { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .page-attendance .attendance-save-bar { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
}
@media (width < 620px) {
  .workspace main { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
}
.page-reports .report-filters select { padding-right: 40px; }

/* Only attendance editing with an open software keyboard changes the fixed chrome. */
@media (width < 1024px) {
  :root[data-attendance-keyboard] { scroll-padding-top: 8px; scroll-padding-bottom: calc(var(--attendance-keyboard-inset) + 80px); }
  :root[data-attendance-keyboard] .workspace:has(.page-attendance) .topbar { position: static; }
  :root[data-attendance-keyboard] .bottom-nav { visibility: hidden; pointer-events: none; }
  :root[data-attendance-keyboard] .page-attendance { padding-bottom: calc(190px + var(--attendance-keyboard-inset)); }
  :root[data-attendance-keyboard] .page-attendance .attendance-save-bar { bottom: var(--attendance-keyboard-inset); }
  :root[data-attendance-keyboard] .attendance-save-feedback small { display: none; }
  :root[data-attendance-keyboard] .page-attendance textarea {
    min-height: 64px; height: min(112px, calc(var(--attendance-visible-height) - 90px));
    max-height: max(64px, calc(var(--attendance-visible-height) - 90px)); scroll-margin-block: 8px 80px;
  }
}
