/* Mobile shell and supporting pages. Desktop layouts remain unchanged. */
.mobile-menu-close { display: none; }
@media (max-width: 800px), (max-width: 1000px) and (max-height: 560px) {
  html { -webkit-text-size-adjust: 100%; }
  .workspace, .main-content, .topbar-leading, .page-heading > div { min-width: 0; }
  .workspace { min-height: 100dvh; margin-right: 0; }
  .mobile-menu { display: inline-flex !important; }
  .main-content {
    padding: 26px max(20px, env(safe-area-inset-right)) 32px max(20px, env(safe-area-inset-left));
  }
  .topbar {
    min-height: 68px;
    height: auto;
    padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
    gap: 12px;
  }
  .topbar-leading { gap: 8px; }
  .topbar-location { font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
  .topbar-location > span { margin-inline: 6px; }
  .topbar-trailing { flex: none; gap: 10px; }
  .level-badge { font-size: 11px; }
  .topbar-avatar { width: 32px; height: 32px; font-size: 12px; }
  .icon-button, .icon-link, .logout-button { min-width: 44px; min-height: 44px; }
  .button { min-height: 46px; font-size: 14px; }
  .text-link { min-height: 44px; white-space: normal; font-size: 13px; }
  .sidebar {
    transform: translateX(100%);
    transition: transform .2s;
    box-shadow: -10px 0 40px #14102a20;
    width: min(300px, calc(100vw - 48px));
    height: 100dvh;
    bottom: auto;
    padding: max(24px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) 20px;
    overflow-y: auto;
    overscroll-behavior: contain;
    visibility: hidden;
  }
  .menu-open .sidebar { visibility: visible; transform: translateX(0); }
  .menu-open .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: #19112f55;
    z-index: 25;
    border: 0;
    backdrop-filter: blur(2px);
  }
  .sidebar > * { flex-shrink: 0; }
  .sidebar > .brand { margin: 0 4px 25px; }
  .mobile-menu-close {
    display: inline-flex;
    position: sticky;
    top: env(safe-area-inset-top, 0px);
    align-self: flex-end;
    margin-bottom: 12px;
    z-index: 1;
    background: var(--navy);
    color: #d9d3e7;
  }
  .mobile-menu-close:hover { background: #ffffff12; color: #fff; }
  .sidebar .brand small { font-size: 11px; }
  .sidebar-label { font-size: 12px; margin-bottom: 8px; }
  .primary-nav { gap: 4px; }
  .primary-nav > a { min-height: 48px; padding: 10px 12px; font-size: 14px; }
  .primary-nav .nav-count { font-size: 12px; }
  .sidebar-divider { margin: 18px 12px; }
  .sidebar-bottom { padding-top: 24px; }
  .foundation-badge { font-size: 11px; }
  .user-card { padding-top: 14px; }
  .user-card > div { min-width: 0; overflow-wrap: anywhere; }
  .user-card strong { font-size: 14px; }
  .user-card small { font-size: 11px; }
  .page-heading { align-items: flex-start; flex-wrap: wrap; gap: 10px 16px; }
  .page-heading h1 { font-size: 29px; }
  .page-heading p { font-size: 14px; line-height: 1.9; }
  .page-heading > .text-link { font-size: 13px; }
  .eyebrow { font-size: 12px; }
  .page-footer {
    flex-wrap: wrap;
    gap: 8px 20px;
    margin: 0 max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
  .page-footer, .page-footer > span:last-child, .page-footer [dir=ltr] { font-size: 11px; }
  .toast-region {
    left: max(16px, env(safe-area-inset-left));
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    max-width: none;
  }
  .toast { font-size: 13px; overflow-wrap: anywhere; }

  /* Login stays comfortable when the keyboard takes up part of the screen. */
  .login-layout, .login-form-side { min-height: 100dvh; }
  .login-form-side {
    padding: max(28px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  }
  .login-form-wrap { max-width: 400px; margin-block: clamp(32px, 7vh, 60px); }
  .login-brand small { font-size: 11px; }
  .login-form-wrap > .eyebrow { font-size: 13px; }
  .login-description { font-size: 14px; }
  .login-form { margin-top: 24px; }
  .login-form label { font-size: 14px; }
  .login-form input, .setting-number input { font-size: 16px; min-height: 48px; }
  .login-form input::placeholder { font-size: 16px; }
  .login-submit { font-size: 15px; }
  .login-note { align-items: baseline; font-size: 12px; line-height: 1.9; }
  .login-footer { max-width: 400px; gap: 12px; flex-wrap: wrap; }
  .login-footer, .login-footer > span { font-size: 11px; }
  .form-error { font-size: 13px; }

  .dashboard-hero { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .hero-copy { min-width: 0; padding: 26px 24px; }
  .hero-copy p { font-size: 14px; }
  .hero-kicker, .hero-subnote { font-size: 12px; }
  .hero-copy .button { font-size: 15px; min-height: 48px; }
  .hero-subnote { display: block; margin-inline-start: 0; }
  .hero-word-area { min-width: 0; padding-inline: 20px; }
  .hero-word > strong { font-size: clamp(34px, 6.5vw, 53px); }
  .hero-word-bottom { font-size: 12px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .stat-card { min-width: 0; padding: 18px; }
  .stat-top { align-items: center; }
  .stat-top > span:first-child { font-size: 13px; }
  .stat-card p { font-size: 12px; line-height: 1.8; }
  .dashboard-lower { grid-template-columns: minmax(0, 1fr); }
  .journey-panel, .recent-panel { padding: 22px 20px 0; min-width: 0; }
  .section-heading { flex-wrap: wrap; gap: 10px; }
  .section-heading h2 { font-size: 17px; }
  .section-heading .eyebrow { font-size: 12px; }
  .count-badge { font-size: 11px; }
  .stage-row { gap: 12px; padding-block: 16px; }
  .stage-row-copy strong { font-size: 14px; }
  .stage-row-copy > span { font-size: 13px; overflow-wrap: anywhere; }
  .stage-row-end { display: flex; font-size: 11px; }
  .stage-row-end .current-label { font-size: 10px; }
  .stage-number { font-size: 12px; }
  .recent-words { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; }
  .recent-word { min-width: 0; min-height: 72px; }
  .recent-word > span:first-child { min-width: 0; overflow-wrap: anywhere; }
  .recent-word > span:first-child strong { font-size: 21px; }
  .recent-word > span:first-child small { font-size: 13px; }
  .recent-score { font-size: 15px; }
  .recent-score small { font-size: 11px; }
  .all-words-link { min-height: 48px; font-size: 13px; }
  .quiet-note { font-size: 12px; line-height: 1.9; }
  .empty-state p { font-size: 14px; }

  .project-manifesto { padding: 28px 24px; }
  .project-manifesto p { font-size: 14px; }
  .project-manifesto > .eyebrow { font-size: 12px; }
  .manifesto-tags > span { font-size: 12px; }
  .project-points { grid-template-columns: minmax(0, 1fr); }
  .project-point { padding: 22px 20px; gap: 12px; }
  .project-point > div { min-width: 0; }
  .project-point h2 { font-size: 16px; }
  .project-point p { font-size: 14px; line-height: 2; overflow-wrap: anywhere; }
  .point-number { flex: none; font-size: 13px; }
  .project-bottom { flex-wrap: wrap; gap: 12px; padding: 22px 20px; }
  .project-bottom > div { min-width: 0; flex: 1; }
  .project-bottom h3 { font-size: 15px; }
  .project-bottom p { font-size: 13px; }
  .project-bottom .button { font-size: 14px; }

  .admin-layout { grid-template-columns: minmax(0, 1fr); }
  .admin-role-banner { flex-wrap: wrap; align-items: flex-start; padding: 20px; }
  .admin-role-banner > div { min-width: 0; flex: 1; }
  .admin-role-banner h2 { font-size: 17px; }
  .admin-role-banner p { font-size: 14px; overflow-wrap: anywhere; }
  .admin-role-banner > .status-pill { margin-inline-start: 0; font-size: 12px; }
  .settings-panel { padding: 22px 20px; }
  .setting-field { align-items: flex-start; gap: 16px; }
  .setting-field label { min-width: 0; }
  .setting-field label strong { font-size: 14px; }
  .setting-field label span { font-size: 13px; }
  .setting-number { gap: 8px; }
  .setting-number input { width: 72px; }
  .setting-number > span { font-size: 12px; }
  .settings-footer p, .settings-panel #settings-feedback { font-size: 13px; }
  .settings-footer p { align-items: flex-start; }
  .settings-footer .button { font-size: 14px; }
  .admin-aside { grid-template-columns: minmax(0, 1fr); }
  .rule-card { padding: 22px 20px; }
  .rule-card h3 { font-size: 18px; }
  .rule-card li { font-size: 14px; line-height: 2; }
  .admin-shortcuts > a { min-height: 48px; font-size: 14px; }
}

@media (max-width: 600px) {
  .main-content { padding-inline: max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-left)); }
  .page-heading h1 { font-size: 27px; }
  .dashboard-hero { grid-template-columns: minmax(0, 1fr); }
  .hero-copy h2 { font-size: 31px; }
  .hero-word-area { display: none; }
  .stat-card { padding: 16px 14px; }
  .stat-top { gap: 8px; }
  .stat-icon { width: 28px; height: 28px; }
  .stat-top > span:first-child { font-size: 12px; }
  .stat-card p { font-size: 12px; }
  .stat-value { font-size: 32px; }
  .stage-row { flex-wrap: wrap; }
  .stage-row-copy { flex-basis: calc(100% - 48px); }
  .stage-row-end { margin-inline-start: 45px; }
  .recent-words { grid-template-columns: minmax(0, 1fr); }
  .project-bottom .button, .settings-footer .button { width: 100%; }
  .setting-field { flex-direction: column; gap: 12px; }
  .setting-number { align-self: flex-start; }
  .setting-number input { width: 88px; }
}

@media (max-width: 420px) {
  .level-badge { display: none; }
  .topbar-leading { gap: 4px; }
  .topbar-location { font-size: 12px; }
  .page-heading h1 { font-size: 25px; }
  .hero-copy { padding: 24px 20px; }
  .hero-copy h2 { font-size: 29px; }
  .stats-grid { gap: 10px; }
  .stat-top { align-items: flex-start; flex-direction: column-reverse; }
  .login-form-side { padding-inline: max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-left)); }
  .login-form-wrap h1 { font-size: 34px; }
  .project-manifesto { padding: 24px 20px; }
  .project-manifesto h2 { font-size: 27px; }
  .project-bottom > span { flex: none; }
}

/* Catalogs and reference pages keep full text and comfortable touch targets. */
@media (max-width: 1000px) {
  body:is([data-page="words"], [data-page="sentences"]) .list-toolbar {
    align-items: stretch;
    flex-wrap: wrap;
  }
  body:is([data-page="words"], [data-page="sentences"]) .filter-tabs button {
    min-height: 44px;
    padding: 9px 12px;
    font-size: 14px;
  }
  body:is([data-page="words"], [data-page="sentences"]) .search-box {
    min-width: 0;
    width: 100%;
    max-width: none;
    min-height: 48px;
    padding: 8px 13px;
  }
  body:is([data-page="words"], [data-page="sentences"]) .search-box input {
    min-width: 0;
    font-size: 16px;
  }
  .word-collections button { font-size: 14px; }
  .word-collections button > span { font-size: 13px; }
  .word-list-controls { gap: 12px; }
  #word-page-summary, #sentence-page-summary { font-size: 13px; }
  .word-pagination { gap: 12px; flex-wrap: wrap; }
  .word-pagination .button { min-height: 44px; font-size: 14px; }
  .word-pagination > span { font-size: 13px; }
  .word-row-name { min-height: 44px; }
  .word-row-name > span, .sentence-copy p { font-size: 15px; }
  .word-row-mastery > div:first-child { font-size: 13px; }
  .word-row-mastery strong { font-size: 15px; }
  .word-row-mastery small, .word-row-status > small { font-size: 12px; }
  .word-row-status .status-pill { font-size: 12px; white-space: normal; }
  .word-row-pronunciation > span { font-size: 15px; }
  .word-row-actions { flex-wrap: wrap; gap: 10px; }
  .word-row-actions .text-link, .word-row-actions .mastery-button {
    min-height: 44px;
    font-size: 14px;
  }
  .word-row-pronunciation .audio-button,
  .sentence-copy .audio-button,
  .word-dialog .audio-button,
  .word-dialog .icon-button {
    min-width: 44px;
    min-height: 44px;
  }
  .sentence-copy > div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 6px;
    align-items: start;
  }
  .sentence-content { align-items: flex-start; }
  .sentence-copy strong { font-size: 19px; line-height: 1.65; }
  .upcoming-words-note p, .upcoming-order-note, .upcoming-word-label { font-size: 14px; }
  .word-dialog { max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain; }
  .word-dialog .detail-note { font-size: 14px; line-height: 1.9; }
  .word-dialog .detail-score { font-size: 14px; }
  .word-dialog .detail-metrics span { font-size: 13px; }
  .word-dialog .word-detail-body h3 { font-size: 16px; }
  .word-dialog .example-row > span { font-size: 17px; overflow-wrap: anywhere; }
  .word-dialog .word-detail-actions button { min-height: 44px; font-size: 14px; white-space: normal; }

  .mindmap {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto;
    min-height: 0;
    gap: 16px;
  }
  .mindmap-connectors { display: none; }
  .map-hub {
    grid-column: 1 / -1;
    grid-row: auto;
    width: 100%;
    height: auto;
    min-height: 88px;
    border-radius: 14px;
    box-shadow: none;
    padding: 16px;
  }
  .map-hub strong { max-width: none; font-size: 15px; }
  .map-hub small { font-size: 13px; }
  .map-branch { grid-column: auto; grid-row: auto; padding: 18px; }
  .map-branch-heading { min-height: 48px; }
  .map-branch-heading strong { font-size: 15px; }
  .map-branch-heading small { font-size: 12px; }
  .map-word-chip { min-height: 44px; min-width: 44px; font-size: 15px; padding: 8px 10px; }
  .map-branch-example { font-size: 16px; overflow-wrap: anywhere; }
  .map-legend { justify-content: flex-start; flex-wrap: wrap; gap: 10px 18px; font-size: 13px; }
  .map-batch-selector button { font-size: 15px; }
  .map-batch-selector button small { font-size: 13px; }
  .map-detail-panel { grid-template-columns: minmax(0, 1fr); padding: 24px; gap: 24px; }
  .map-detail-panel > * { min-width: 0; }
  .map-detail-grammar { display: block; border-inline-start: 0; border-top: 1px solid var(--line); padding-inline-start: 0; padding-top: 20px; }
  .map-detail-intro > p, .prerequisite p, .map-detail-grammar .grammar-item p,
  .map-detail-grammar .grammar-note, .map-rules span { font-size: 14px; line-height: 1.9; }
  .map-detail-examples h3, .map-detail-grammar h3, .map-rules strong { font-size: 16px; }
  .map-detail-examples .example-row > span { font-size: 17px; overflow-wrap: anywhere; }
  .map-detail-examples .example-row .audio-button,
  .map-sentence-grid .example-row .audio-button,
  .map-word-audio .audio-button { min-height: 44px; min-width: 44px; flex-shrink: 0; }
  .map-word-audio .audio-button, .map-word-audio > span { font-size: 14px; }
  .map-detail-grammar .grammar-item strong { font-size: 17px; overflow-wrap: anywhere; }
  .stage-detail-chips > span { font-size: 14px; }
  .prerequisite small, .map-detail-panel .small-note, .map-detail-panel .eyebrow { font-size: 13px; }
  .grammar-requirements summary { font-size: 14px; min-height: 44px; padding: 10px 0; }
  .grammar-requirements > div > span { font-size: 14px; }
  .map-sentence-heading p { font-size: 14px; }
  .map-sentence-grid .example-row > span { font-size: 16px; }
  .map-sentence-stage-heading { flex-wrap: wrap; }
  .map-sentence-stage-heading h3 { font-size: 16px; }
  .map-sentence-count, .map-sentence-stage-heading .map-sentence-count { font-size: 13px; white-space: normal; }

  .grammar-index nav a { min-height: 48px; font-size: 15px; }
  .grammar-index nav bdi { font-size: 17px; }
  .grammar-index-note, .grammar-index .eyebrow { font-size: 14px; }
  .grammar-example .audio-button, .grammar-dialog .icon-button {
    min-width: 44px;
    min-height: 44px;
  }
  .grammar-practice .button, .grammar-article-footer .button, .grammar-dialog-footer .button { min-height: 48px; font-size: 15px; }
  .grammar-section .eyebrow { font-size: 13px; }
  .grammar-article-footer p, .grammar-dialog-footer > span { font-size: 13px; line-height: 1.8; }
}

@media (max-width: 600px) {
  .word-summary-strip { margin-bottom: 22px; }
  .word-summary-strip > div {
    flex: 1 1 0;
    min-width: 0;
    padding: 16px 7px;
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
  .word-summary-strip > div > span { font-size: 13px; min-height: 40px; display: flex; align-items: center; }
  .word-summary-strip strong { font-size: 22px; margin-inline-start: 0; }
  .word-summary-strip small { font-size: 12px; }
  body:is([data-page="words"], [data-page="sentences"]) .list-toolbar > .filter-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; gap: 6px; }
  .word-collections { gap: 7px; }
  .word-collections button { padding: 10px 8px; gap: 6px; min-width: 0; }
  .word-collections button .icon { display: none; }
  .word-list-controls { align-items: flex-start; }
  .word-list-controls > span { width: 100%; }
  .word-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 105px);
    padding: 18px 14px;
    gap: 16px 12px;
  }
  .word-row-name { grid-column: 1; grid-row: 1; flex-direction: column; align-items: flex-start; gap: 4px; }
  .word-row-pronunciation { grid-column: 2; grid-row: 1; flex-wrap: wrap; justify-content: flex-end; }
  .word-row-mastery { grid-column: 1; grid-row: 2; max-width: none; }
  .word-row-status { grid-column: 2; grid-row: 2; gap: 5px; }
  .word-row-actions { grid-column: 1 / -1; grid-row: 3; }
  .word-row-actions .mastery-button { white-space: normal; padding-inline: 10px; }
  .sentence-row { padding: 18px 14px; gap: 17px 12px; grid-template-columns: minmax(0, 1fr) minmax(0, 105px); }
  .sentence-content { gap: 9px; }
  .sentence-row-number { min-width: 30px; min-height: 32px; font-size: 13px; padding-inline: 6px; }
  .sentence-copy strong { font-size: 18px; }
  .sentence-copy p { font-size: 15px; }
  .word-dialog { width: calc(100% - 20px); max-width: none; max-height: calc(100dvh - 20px); border-radius: 14px; }
  .word-dialog .dialog-header { padding: 12px 16px; }
  .word-dialog .word-detail-body { padding: 20px 16px; }
  .word-dialog .word-detail-body h2 { font-size: 38px; overflow-wrap: anywhere; }
  .word-dialog .word-detail-pronounce { flex-wrap: wrap; }
  .word-dialog .example-row { padding: 10px; gap: 6px; }
  .word-dialog .detail-metrics { gap: 12px; }

  .mindmap { grid-template-columns: minmax(0, 1fr); gap: 14px; padding-top: 0; }
  .map-branch { padding: 16px; }
  .map-hub { align-items: center; gap: 6px; }
  .map-detail-panel, .map-sentence-library { padding: 20px 16px; }
  .map-detail-intro h2 { font-size: 23px; }
  .map-detail-examples .example-row, .map-sentence-grid .example-row { padding: 10px; gap: 7px; }
  .map-sentence-heading { gap: 12px; }
  .map-sentence-heading h2 { font-size: 23px; }
  .map-sentence-heading p { font-size: 14px; }
  .map-sentence-stage-heading .map-sentence-count { margin-inline-start: 0; }
  .map-sentence-grid { grid-template-columns: minmax(0, 1fr); }
  .map-sentence-note { font-size: 14px; }
  .map-rules { grid-template-columns: minmax(0, 1fr); }

  .grammar-layout { min-width: 0; gap: 18px; }
  .grammar-index { padding: 20px 16px; }
  .grammar-index nav { margin-inline: 0; }
  .grammar-article-intro, .grammar-section, .grammar-dialog-body .grammar-section { padding: 24px 16px; }
  .grammar-article-intro h2 { font-size: 24px; }
  .grammar-article-intro p, .grammar-section > p, .grammar-water-note > p { font-size: 15px; line-height: 1.95; }
  .grammar-section-heading { align-items: flex-start; gap: 10px; }
  .grammar-section-heading h2 { font-size: 20px; }
  .grammar-section .grammar-form { min-width: 48px; font-size: 20px; }
  .grammar-example { padding: 13px 10px; align-items: flex-start; gap: 7px; }
  .grammar-example p { font-size: 19px; line-height: 1.7; }
  .grammar-example span { font-size: 14px; line-height: 1.9; display: block; }
  .grammar-example .audio-button { padding: 8px; }
  .grammar-pattern { font-size: 14px; gap: 10px; padding: 16px 10px; }
  .grammar-takeaway { padding: 14px; }
  .grammar-takeaway strong, .grammar-takeaway p { font-size: 14px; line-height: 1.9; }
  .grammar-article-types { grid-template-columns: minmax(0, 1fr); }
  .grammar-article-types p { font-size: 15px; }
  .grammar-article-types p[lang] { font-size: 19px; }
  .grammar-article-types small { font-size: 14px; }
  .grammar-practice { padding: 16px 12px; gap: 16px; }
  .grammar-practice p, .grammar-locked p, .grammar-section .grammar-empty-examples { font-size: 14px; }
  .grammar-practice h3 { font-size: 17px; }
  .grammar-practice .button { white-space: normal; }
  .grammar-dialog-header { padding: 14px 16px; gap: 10px; }
  .grammar-dialog-header h2 { font-size: 21px; }
  .grammar-dialog-footer { padding: 12px 16px; gap: 8px; }
}

/* The lesson stays readable and operable with a thumb on narrow screens. */
@media (max-width: 1020px) {
  body[data-page="learn"] .lesson-layout { grid-template-columns: minmax(0, 1fr); }
  body[data-page="learn"] .lesson-layout > * { min-width: 0; }
  .lesson-settings .learning-modes { min-width: 0; flex: 0 0 38%; }
  .lesson-settings .learning-modes fieldset { min-width: 0; max-width: 100%; }
  .lesson-settings .learning-mode-options { flex-wrap: wrap; }
}
@media (max-width: 800px), (max-width: 1000px) and (max-height: 560px) {
  body[data-page="learn"] .lesson-topline { gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
  body[data-page="learn"] .lesson-topline > .text-link,
  body[data-page="learn"] .lesson-topline > span { font-size: 12px; color: #786a87; }
  .lesson-stage-header { gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
  .lesson-stage-header .eyebrow { font-size: 12px; }
  .lesson-stage-header h1 { font-size: 26px; }
  .lesson-stage-dots { flex-shrink: 0; }
  .lesson-layout { gap: 18px; }
  .question-card-meta { padding: 14px 16px; gap: 10px; flex-wrap: wrap; }
  .question-card-meta .question-type { font-size: 13px; }
  .question-card-meta .subtle-pill { font-size: 11px; }
  .question-body { padding: 20px; }
  .question-focus { padding: 18px 16px; margin-bottom: 18px; }
  .question-focus .question-prompt { font-size: 14px; margin-bottom: 10px; }
  .question-target { font-size: clamp(24px, 6vw, 30px); line-height: 1.75; }
  .question-target[dir="ltr"] { font-size: clamp(28px, 7vw, 40px); letter-spacing: 0; }
  .question-prompt { font-size: 17px; line-height: 1.85; }
  .lesson-input-toolbar { margin-bottom: 20px; gap: 8px 12px; }
  .question-audio { min-height: 44px; font-size: 13px; padding: 9px 13px; }
  .listen-note, .answer-label, .input-hint { font-size: 12px; line-height: 1.85; color: #82718f; }
  .answer-label { margin-bottom: 10px; }
  .written-answer { font-size: 18px; min-height: 54px; padding: 14px; }
  .written-answer::placeholder { font-size: 16px; }
  .choice-option { min-height: 56px; padding: 12px; gap: 10px; text-align: start; }
  .choice-text, .voice-enabled .choice-text { font-size: 16px; line-height: 1.65; overflow-wrap: anywhere; }
  .choice-letter { width: 28px; height: 28px; font-size: 12px; }
  .choice-check { flex: none; }
  .question-actions { gap: 10px; padding-top: 16px; margin-top: 20px; flex-wrap: wrap; }
  .question-actions .button-primary, .question-actions .button-quiet { min-height: 48px; font-size: 14px; padding: 11px 14px; }
  .question-actions .input-hint { flex: 1 1 180px; }
  .last-sentence-card { padding: 20px; gap: 14px; }
  .last-sentence-ar { font-size: 16px; }
  .last-sentence-en { font-size: 21px; }
  .last-sentence-card .mastery-button { min-height: 48px; font-size: 14px; }
  .lesson-mini-stat { padding: 16px; }
  .lesson-mini-stat > span { font-size: 13px; }
  .lesson-mini-stat strong { font-size: 20px; }
  .lesson-mini-stat small { font-size: 13px; }
  .lesson-history-button { padding: 16px; min-height: 66px; }
  .lesson-history-button strong { font-size: 14px; }
  .lesson-history-button small { font-size: 12px; }
  .feedback { padding: 20px; }
  .feedback-heading h3 { font-size: 17px; }
  .feedback-heading p, .feedback-explanation, .attempt-label { font-size: 13px; line-height: 1.9; }
  .feedback-heading > div { min-width: 0; }
  .correct-answer { gap: 10px; }
  .correct-answer strong { font-size: 22px; line-height: 1.65; overflow-wrap: anywhere; }
  .correct-answer > span { font-size: 14px; }
  .answer-comparison { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .answer-comparison > div, .answer-comparison .correct-answer { padding: 16px; }
  .answer-comparison h4 { font-size: 13px; }
  .answer-comparison .correct-answer > span { font-size: 13px; }
  .diagnosis h4 { font-size: 16px; }
  .diagnosis > p, .diagnosis .eyebrow, .diagnosis-confirmation > p { font-size: 13px; line-height: 1.9; }
  .diagnosis-tokens { gap: 8px; }
  .diagnosis-token { min-width: 44px; min-height: 48px; padding: 8px 12px; font-size: 19px; }
  .structure-select { min-height: 44px; font-size: 13px; white-space: normal; overflow-wrap: anywhere; }
  .structure-select > span { font-size: 15px; }
  .diagnosis-actions { gap: 8px; }
  .diagnosis-actions .button, .diagnosis-actions .text-link { min-height: 48px; font-size: 13px; }
  .diagnosis-detail strong { font-size: 17px; }
  .diagnosis-detail > span, .diagnosis-detail > small { font-size: 13px; }
  .next-question { min-height: 48px; font-size: 14px; }
  .lesson-success-card { min-height: 128px; padding: 20px 16px; }
  .lesson-success-copy > strong { font-size: 19px; }
  .lesson-success-answer { font-size: 20px; }
  .completion-panel { padding: 28px 20px; }
  .completion-panel > p { font-size: 14px; }
  .completion-stats { gap: 24px; flex-wrap: wrap; }
  .completion-stats span { font-size: 13px; }
  .completion-actions { flex-wrap: wrap; }
  .completion-actions .button { flex: 1 1 180px; }

  .lesson-settings { flex-direction: row; margin-bottom: 16px; }
  .lesson-settings .learning-modes, .lesson-audio-settings { width: auto; padding: 12px 16px; }
  .lesson-settings .learning-modes { gap: 8px; }
  .lesson-settings .learning-modes fieldset { width: 100%; }
  .lesson-settings .learning-modes legend, .lesson-audio-settings h2 { font-size: 15px; }
  .lesson-settings .learning-mode-options { display: flex; width: 100%; gap: 10px; }
  .lesson-settings .learning-mode-options label { min-height: 48px; flex: 1; font-size: 14px; padding: 10px 12px; }
  .lesson-settings #learning-mode-note { font-size: 12px; min-height: 46px; line-height: 1.9; color: #82758e; }
  .lesson-audio-settings { border-inline-start: 1px solid var(--line); border-top: 0; }
  .lesson-audio-settings p { font-size: 12px; color: #82758e; }
  .lesson-audio-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .lesson-audio-options .lesson-voice-toggle { display: flex; flex-direction: column; min-width: 0; min-height: 82px; padding: 8px 6px; gap: 6px; border-radius: 12px; font-size: 13px; line-height: 1.5; white-space: normal; }
  .lesson-audio-options .lesson-voice-toggle > span:not(.voice-toggle-track) { display: flex; flex: 1; align-items: center; justify-content: center; }
  .lesson-audio-options .lesson-voice-toggle > .icon { display: none; }
  .lesson-audio-options .voice-toggle-track { flex: none; width: 30px; height: 18px; }
  .lesson-audio-options .voice-toggle-track i { width: 14px; height: 14px; }
  .lesson-voice-panel { padding: 16px; }
  .voice-status-label { font-size: 13px; flex: 1; min-width: 0; }
  .voice-status-label > i { flex: none; }
  .voice-elapsed { font-size: 12px; }
  .voice-answer-guide { font-size: 13px; color: #82718f; }
  .voice-heard > span { font-size: 12px; color: #82718f; }
  .voice-heard > p { font-size: 20px; }
  .voice-submit-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .voice-submit-actions .button { min-width: 0; min-height: 48px; font-size: 14px; padding: 10px 8px; white-space: normal; }
  .lesson-voice-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .lesson-voice-actions > button { min-height: 44px; padding: 8px; font-size: 13px; flex-wrap: wrap; }
  .lesson-voice-actions small { font-size: 12px; }
  .voice-speak-note { font-size: 13px; }
  .voice-speak-note button { min-height: 44px; font-size: 13px; }
  .voice-assistance-note, .lesson-voice-notice { font-size: 13px; }

  .learning-history-dialog { max-height: 100dvh; }
  .history-header { padding: 18px 16px 14px; }
  .history-header h2 { font-size: 24px; }
  .history-header .eyebrow, .history-header p { font-size: 12px; }
  .history-header .icon-button { min-width: 44px; min-height: 44px; }
  .history-tabs { padding: 0 16px 14px; gap: 10px; }
  .history-tabs > button { min-height: 48px; font-size: 14px; padding: 10px 8px; }
  .history-panel { padding: 16px; }
  .history-tab-description { font-size: 13px; }
  .history-entry { padding: 16px; }
  .history-entry h3 { font-size: 16px; }
  .history-entry-meta time, .history-entry-meta .status-pill { font-size: 12px; }
  .history-answer-grid h4 { font-size: 12px; }
  .history-answer-grid p { font-size: 19px; }
  .history-correct > span { font-size: 14px; }
  .history-error-count, .history-mastery-marker { font-size: 13px; line-height: 1.8; }
  .history-mastery-marker { min-height: 24px; }
  .history-entry-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .history-entry-actions .mastery-button, .history-entry-actions .text-link { min-width: 0; min-height: 56px; padding: 8px; font-size: 13px; white-space: normal; }
  .history-entry-actions [data-history-grammar] { grid-column: 1 / -1; }
  .history-action-note { padding: 10px 16px; font-size: 12px; }
  .history-footer { padding: 12px 16px max(12px, env(safe-area-inset-bottom)); gap: 10px; }
  .history-footer > span { font-size: 12px; }
  .history-footer .button { min-height: 48px; font-size: 13px; padding: 10px 12px; }
}
@media (max-width: 600px) {
  body[data-page="learn"] .main-content { padding-top: 16px; }
  .batch-progress-compact { padding: 14px 16px; gap: 12px; margin-bottom: 14px; }
  .batch-progress-compact .eyebrow { font-size: 11px; }
  .batch-progress-compact .batch-progress-copy p { font-size: 12px; }
  .batch-progress.batch-progress-learning { padding: 14px 16px; gap: 7px; }
  .batch-progress-learning .batch-remaining-heading { font-size: 22px; min-height: 3.3em; }
  .batch-progress-learning .batch-mastery-summary { font-size: 13px; }
  .lesson-settings { flex-direction: column; }
  .lesson-settings .learning-modes, .lesson-audio-settings { width: 100%; }
  .lesson-settings .learning-modes { flex-basis: auto; gap: 4px; }
  .lesson-settings .learning-modes legend, .lesson-audio-settings h2 { margin-bottom: 8px; }
  .lesson-settings #learning-mode-note { min-height: 46px; }
  .lesson-audio-settings { border-inline-start: 0; border-top: 1px solid var(--line); }
  /* The switches already describe these optional features; keep their help available to assistive technology. */
  #lesson-audio-help { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  body[data-page="learn"] .lesson-topline { margin-bottom: 8px; }
  .lesson-stage-header { margin-bottom: 12px; }
}
@media (max-width: 380px) {
  .question-body, .feedback { padding: 16px 12px; }
  .question-focus { padding: 16px 12px; }
  .question-actions .button-primary { flex-basis: 100%; }
  .question-actions .button-quiet { width: 100%; }
  .voice-submit-actions { grid-template-columns: minmax(0, 1fr); }
  .lesson-audio-options { gap: 6px; }
  .lesson-audio-options .lesson-voice-toggle { padding-inline: 4px; font-size: 12px; }
  .history-panel { padding: 12px; }
  .history-entry { padding: 14px 12px; }
}
@media (max-width: 900px) and (max-height: 560px) {
  .history-header { padding: 10px 16px; align-items: center; }
  .history-header h2 { font-size: 20px; margin: 0; }
  .history-header .eyebrow, .history-header p { display: none; }
  .history-tabs { padding: 0 16px 10px; }
  .history-tabs > button { min-height: 44px; padding: 7px; }
  .history-action-note { padding: 6px 16px; }
  .history-footer { padding: 8px 16px; }
  .history-footer > span { display: none; }
  .history-footer .button { min-height: 44px; }
}
