/* A separate phone workspace, not a scaled desktop dashboard. */
#mobileWorkspace[hidden], .mobile-page[hidden] { display: none !important; }
@media (max-width: 760px) {
  html.mobile-workspace-layout { scroll-padding-top: 72px; }
  .mobile-workspace-layout #workspaceScreen > .compact-app { display: none; }
  .mobile-workspace-layout body { overflow-y: auto; }
  #mobileWorkspace { min-height: 100dvh; background: var(--bg); color: var(--text); padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .mobile-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; padding: max(12px, env(safe-area-inset-top)) 20px 12px; border-bottom: 1px solid var(--line); background: var(--surface-solid); }
  .mobile-header strong { font-size: 19px; letter-spacing: -.5px; color: var(--brand-dark); }
  #mobileContext { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--muted); }
  .mobile-pages { max-width: 560px; margin: auto; padding: 24px 16px; }
  .mobile-page { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
  .mobile-page-heading { display: flex; align-items: center; gap: 12px; }
  .mobile-page h1 { margin: 0; font-size: 28px; line-height: 1.15; color: var(--brand-dark); }
  .mobile-page h1:focus { outline: none; }
  .mobile-page-hint { margin: -4px 0 4px; font-size: 15px; line-height: 1.5; color: var(--muted); }
  .mobile-nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); gap: 4px; border-top: 1px solid var(--line); background: var(--surface-solid); box-shadow: 0 -4px 24px rgba(0,0,0,.04); }
  .mobile-nav button { min-height: 52px; min-width: 0; padding: 8px 2px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }
  .mobile-nav button[aria-selected="true"] { color: var(--primary-text); background: var(--primary-bg); }
  .mobile-page button, .mobile-page input, .mobile-page select { touch-action: manipulation; }
  .mobile-primary, .mobile-secondary { min-height: 48px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; font: inherit; font-size: 16px; font-weight: 600; cursor: pointer; }
  .mobile-primary { background: var(--primary-bg); color: var(--primary-text); border-color: transparent; }
  .mobile-secondary { background: var(--surface-solid); color: var(--brand-dark); }
  #mobile-lesson .sidebar-card-setup { padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-solid); color: var(--text); margin: 0; }
  #mobile-lesson .sidebar-card-head { display: none; }
  #mobile-lesson label { display: block; color: var(--text); margin: 0 0 8px; font-size: 14px; font-weight: 600; }
  #mobile-lesson input, #mobile-lesson select { height: 52px; margin: 0 0 20px; width: 100%; font-size: 16px; border: 1px solid var(--line); background: var(--surface-muted); color: var(--text); }
  #mobile-lesson select { margin-bottom: 0; }
  #mobile-students .student-picker { display: block; padding: 0; border: 0; background: transparent; box-shadow: none; overflow: visible; }
  #mobile-students .student-picker-head { display: flex; flex-direction: column; align-items: stretch; gap: 12px; padding-bottom: 16px; }
  #mobile-students .picker-controls { display: flex; flex-wrap: nowrap; justify-content: space-between; gap: 6px; }
  #mobile-students .count-chip { margin-right: auto; font-size: 13px; padding: 8px; }
  #mobile-students .page-button { width: 44px; height: 44px; flex-shrink: 0; }
  #mobile-students .page-indicator { min-width: 48px; padding: 8px; font-size: 14px; }
  #mobile-students .student-grid { --student-grid-columns: 1; display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: none; grid-auto-rows: auto; gap: 8px; height: auto; overflow: visible; }
  #mobile-students .student-tile { display: flex; align-items: center; justify-content: flex-start; text-align: left; gap: 14px; min-height: 64px; padding: 12px 16px; border-radius: 12px; background: var(--surface-solid); }
  #mobile-students .student-tile strong { font-size: 16px; line-height: 1.35; overflow-wrap: anywhere; }
  #mobile-students .tile-avatar { width: 36px; height: 36px; flex-shrink: 0; font-size: 15px; }
  #mobile-students .student-tile-active { border: 2px solid var(--brand); background: var(--brand-soft); }
  #mobile-students .empty-students { padding: 24px 16px; min-height: 240px; }
  #mobile-prompt .selected-student-card { padding: 16px; border-radius: 16px; background: var(--surface-solid); }
  #mobile-prompt .selected-top { display: block; }
  #mobile-prompt .selected-identity { display: flex; gap: 12px; }
  #mobile-prompt .selected-identity h3 { font-size: 21px; line-height: 1.2; }
  #mobile-prompt .selected-quick-chips { margin-top: 10px; }
  #mobile-prompt .mobile-interests { margin-top: 12px; width: 100%; }
  #mobileWorkspace:not(.mobile-interests-open) .selected-details { display: none; }
  #mobile-prompt .selected-details { margin-top: 12px; gap: 8px; }
  #mobile-prompt .prompt-actions-panel { display: flex; flex-direction: column; gap: 16px; padding: 0; border: 0; background: transparent; }
  #mobile-prompt .bottom-toolbar { display: flex; flex-direction: column; order: -1; gap: 12px; padding: 0; border: 0; background: transparent; overflow: visible; }
  #mobile-prompt .toolbar-copy-group { display: grid; gap: 10px; width: 100%; }
  #mobile-prompt .toolbar-action { width: 100%; min-height: 54px; font-size: 16px; border-radius: 12px; }
  #mobile-prompt .toolbar-preview-button { width: 100%; min-height: 48px; border-radius: 12px; font-size: 15px; }
  #mobile-prompt .toolbar-ai-links { width: 100%; display: flex; gap: 10px; padding: 12px; border-radius: 12px; background: var(--surface-solid); overflow: visible; }
  #mobile-prompt .ai-shortcut, #mobile-prompt .help-button { width: 46px; height: 46px; }
  #mobile-prompt .prompt-drawer { padding: 16px; border-radius: 16px; }
  #mobile-prompt .prompt-preview { height: auto; max-height: 55dvh; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
  #mobile-prompt .help-tooltip { position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); top: auto; width: auto; max-height: 60dvh; overflow-y: auto; z-index: 80; }
  #mobile-more .sidebar-nav { display: flex; flex-direction: column; gap: 8px; padding: 0; margin: 0; border: 0; background: transparent; }
  #mobile-more .sidebar-link { display: flex; align-items: center; justify-content: space-between; min-height: 60px; padding: 16px; font-size: 16px; font-weight: 600; color: var(--text); border: 1px solid var(--line); border-radius: 12px; background: var(--surface-solid); }
  #mobile-more #logoutBtn { margin-top: 12px; color: var(--danger-text); }
  .mobile-modal-open body { overflow: hidden; }
  .mobile-modal-open .mobile-nav { display: none; }
  .mobile-workspace-layout .modal-backdrop { padding: 0; align-items: stretch; }
  .mobile-workspace-layout .modal-shell { display: flex; flex-direction: column; width: 100%; height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0; overflow: hidden; }
  .mobile-workspace-layout .modal-sidebar { flex-shrink: 0; padding: max(16px, env(safe-area-inset-top)) 16px 12px; gap: 10px; background: var(--surface-solid); color: var(--text); border-bottom: 1px solid var(--line); }
  .mobile-workspace-layout .modal-sidebar h2 { font-size: 22px; padding-right: 48px; color: var(--brand-dark); }
  .mobile-workspace-layout .modal-nav { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
  .mobile-workspace-layout .modal-nav-button { flex: 0 0 auto; width: auto; max-width: 190px; min-height: 44px; padding: 10px 14px; font-size: 14px; color: var(--text); background: var(--surface-muted); border: 1px solid var(--line); }
  .mobile-workspace-layout .modal-nav-button-active { background: var(--brand-soft); border-color: var(--brand); }
  .mobile-workspace-layout .modal-content { position: static; flex: 1 1 auto; min-height: 0; padding: 20px 16px max(24px, env(safe-area-inset-bottom)); overflow-y: auto; background: var(--surface-solid); }
  .mobile-workspace-layout .modal-close { position: absolute; top: max(10px, env(safe-area-inset-top)); right: 12px; z-index: 5; width: 44px; height: 44px; }
  .mobile-workspace-layout .modal-content h3 { padding-right: 0; }
  .mobile-workspace-layout input, .mobile-workspace-layout select, .mobile-workspace-layout textarea { font-size: 16px; }
  #authScreen { padding: 20px 16px 36px; }
  #authScreen .standalone-brand { font-size: 24px; margin-bottom: 24px; }
  #authScreen .auth-shell { display: flex; flex-direction: column; gap: 28px; max-width: 480px; }
  #authScreen .auth-card-login { width: 100%; padding: 0; border: 0; background: transparent; box-shadow: none; }
  #authScreen .auth-mode-switch { margin-bottom: 24px; }
  #authScreen .auth-label { display: block; margin: 14px 0 7px; font-size: 14px; }
  #authScreen input { height: 52px; font-size: 16px; }
  #authScreen .auth-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
  #authScreen .auth-provider { min-height: 52px; padding: 12px 16px; font-size: 16px; }
  #authScreen #emailAuthBtn { order: -2; }
  #authScreen #authForgotPasswordBtn { order: -1; min-height: 44px; margin-top: -6px; }
  #authScreen .auth-information { width: 100%; }
  #authScreen .auth-intro-card { padding: 0; border: 0; background: transparent; box-shadow: none; }
  #authScreen .auth-intro-card h1 { font-size: 25px; line-height: 1.2; }
  #authScreen .walkthrough-grid { display: flex; flex-direction: column; gap: 12px; }
  #authScreen .walkthrough-card { display: grid; grid-template-columns: 28px minmax(0,1fr); gap: 6px 12px; padding: 16px; }
  #authScreen .walkthrough-step { grid-row: 1 / 3; margin: 0; width: 28px; height: 28px; }
  #authScreen .walkthrough-card h2 { font-size: 16px; margin: 0; }
  #authScreen .walkthrough-card p { grid-column: 2; margin: 0; font-size: 14px; }
  [hidden] { display: none !important; }
}
