/* Learning area only: preserve the shared header and footer on other routes. */
body.learning-workspace-page .site-footer { display:none !important; }
html.workspace-screen { height:100%; overflow:hidden; overscroll-behavior:none; scrollbar-gutter:auto; }
body.learning-workspace-page {
  position:fixed; top:var(--workspace-visible-top,0px); inset-inline:0;
  width:100%; height:var(--workspace-visible-height,100dvh); min-height:0;
  overflow:hidden; overscroll-behavior:none; margin:0;
}
body.learning-workspace-page #main-content {
  display:flex; flex-direction:column; flex:1 1 0 !important; min-height:0; overflow:hidden;
}
body.learning-workspace-page #workspaceToolbarHome { flex-shrink:0; position:relative; top:auto; }
body.learning-workspace-page .workspace-viewport {
  flex:1 1 0; min-height:0; width:100%; margin:0 auto; padding-bottom:0 !important;
  overflow:hidden; box-sizing:border-box;
}
body.learning-workspace-page .workspace-viewport.workspace-picker { overflow-y:auto; }
body.learning-workspace-page #workspaceGridContainer { height:100%; min-height:0; max-height:100%; }
body.learning-workspace-page #workspaceGridContainer.mode-ai .slot-center {
  height:100%; min-height:0; display:flex; flex-direction:column; overflow:hidden;
}
body.learning-workspace-page #workspaceGridContainer.mode-ai #workspaceOrientationBar { flex-shrink:0; }
body.learning-workspace-page #workspaceGridContainer.mode-ai #workspaceTutorSlot {
  flex:1 1 0 !important; height:auto !important; max-height:100%; min-height:0 !important;
}
body.learning-workspace-page #workspaceGridContainer #workspaceTutorSlot #pnielAiWorkspace {
  height:100% !important; max-height:100% !important; min-height:0 !important;
  flex:1 1 0 !important; transition:none !important;
}
body.learning-workspace-page #workspaceGridContainer #workspaceTutorSlot #pnielAiMessages {
  flex:1 1 0 !important; min-height:0 !important; overflow-y:auto; overscroll-behavior-y:contain;
}
body.learning-workspace-page #workspaceGridContainer #workspaceContentReader {
  height:100%; max-height:100%; min-height:0; overflow-y:auto; overscroll-behavior-y:contain;
  -webkit-overflow-scrolling:touch; touch-action:pan-y pinch-zoom;
}
@media (min-width:1025px) {
  /* The rail belongs to the fixed learning frame, so it needs no sticky offset. */
  body.learning-workspace-page #workspaceGridContainer.mode-content #workspaceLauncherSlot {
    position:relative; top:0; align-self:start;
  }
  body.learning-workspace-page #workspaceGridContainer.mode-content.ai-teach-open #workspaceTutorSlot {
    position:relative !important; top:0 !important; height:100% !important; max-height:100% !important;
  }
}
@media (max-width:1024px) {
  body.learning-workspace-page #workspaceToolbarControls .workspace-course-selector-wrap {
    flex:0 1 auto; width:auto; max-width:100%;
  }
  body.learning-workspace-page #workspaceToolbarControls .workspace-course-btn {
    width:auto; max-width:100%;
  }
  body.learning-workspace-page #workspaceToolbarControls .workspace-course-name { max-width:220px; }
  body.learning-workspace-page .workspace-viewport { padding-top:0 !important; }
  body.learning-workspace-page #workspaceGridContainer.mode-content:not(.ai-teach-open) #workspaceContentReader {
    height:calc(100% - 64px - env(safe-area-inset-bottom,0px));
  }
  body.learning-workspace-page .workspace-mobile-bar { bottom:var(--workspace-visible-bottom,0px); }
  body.learning-workspace-page #workspaceGridContainer.mode-content.ai-teach-open #workspaceTutorSlot {
    bottom:var(--workspace-visible-bottom,0px) !important;
    height:min(var(--workspace-frame-height),max(320px,calc(var(--workspace-frame-height) * .6667 - 48px))) !important;
    max-height:var(--workspace-frame-height) !important; min-height:0 !important;
  }
  body.learning-workspace-page.workspace-keyboard-open #workspaceGridContainer.mode-content.ai-teach-open #workspaceTutorSlot,
  body.learning-workspace-page.workspace-assistant-expanded #workspaceGridContainer.mode-content.ai-teach-open #workspaceTutorSlot {
    height:var(--workspace-frame-height) !important;
  }
  body.learning-workspace-page.workspace-keyboard-open #workspaceGridContainer #workspaceTutorSlot {
    padding-bottom:0 !important;
  }
  body.learning-workspace-page #workspaceGridContainer #pnielAiInput { font-size:16px !important; }
  body.learning-workspace-page #workspaceGridContainer #pnielAiWorkspace .pniel-ai-bottom-area {
    padding:4px 10px 6px !important; flex-shrink:0;
  }
  body.learning-workspace-page.workspace-keyboard-open #workspaceGridContainer #pnielAiWorkspace .pniel-ai-bottom-area {
    padding-bottom:12px !important;
  }
  body.learning-workspace-page #workspaceGridContainer #pnielAiWorkspace .pniel-ai-composer-area {
    padding:0 !important; display:flex; flex-direction:column; gap:4px;
  }
  body.learning-workspace-page.workspace-keyboard-open #workspaceGridContainer .pniel-ai-composer-subtext {
    order:-1; margin:0 !important; font-size:10px !important; line-height:1.3 !important;
  }
  /* Both mobile chats use the same compact row, regardless of keyboard state. */
  body.learning-workspace-page #workspaceGridContainer #pnielAiWorkspace #pnielAiForm {
    min-height:60px !important; padding:6px 8px !important; border-radius:28px !important;
    grid-template-columns:42px minmax(0,1fr) 42px;
    grid-template-rows:minmax(46px,auto); gap:4px 8px !important;
    align-items:end !important; direction:ltr !important;
  }
  /* Keep all existing authorization/consent gates that hide the form. */
  body.learning-workspace-page #workspaceGridContainer #pnielAiWorkspace #pnielAiForm:not([style*="display:none"]):not([style*="display: none"]) {
    display:grid !important;
  }
  body.learning-workspace-page #workspaceGridContainer #pnielAiWorkspace #pnielAiForm[data-composer-mode="content_assistant"] {
    grid-template-columns:minmax(0,1fr) 42px;
  }
  body.learning-workspace-page #workspaceGridContainer #pnielAiWorkspace #pnielAiForm[data-composer-mode="ai_tutor"].has-photo {
    grid-template-rows:auto minmax(46px,auto);
  }
  body.learning-workspace-page #workspaceGridContainer #pnielAiWorkspace #pnielAiForm #pnielAiInput {
    grid-column:2; grid-row:1; align-self:end; width:100%; box-sizing:border-box;
    height:var(--workspace-input-height,42px) !important; min-height:42px !important; max-height:90px !important;
    min-width:0; padding:9px 4px !important; line-height:1.5 !important;
    overflow-y:auto !important; direction:rtl; text-align:right;
  }
  body.learning-workspace-page #workspaceGridContainer #pnielAiWorkspace #pnielAiForm[data-composer-mode="content_assistant"] #pnielAiInput {
    grid-column:1;
  }
  body.learning-workspace-page #workspaceGridContainer #pnielAiWorkspace #pnielAiForm #pnielAiInput::placeholder {
    white-space:nowrap;
  }
  body.learning-workspace-page #workspaceGridContainer #pnielAiWorkspace #pnielAiForm :is(#pnielAiSendBtn,#pnielAiPhotoHost) {
    grid-row:1; align-self:end;
  }
  body.learning-workspace-page #workspaceGridContainer #pnielAiWorkspace #pnielAiForm #pnielAiSendBtn {
    grid-column:3; width:42px !important; height:42px !important;
    min-width:42px !important; min-height:42px !important;
  }
  body.learning-workspace-page #workspaceGridContainer #pnielAiWorkspace #pnielAiForm[data-composer-mode="content_assistant"] #pnielAiSendBtn {
    grid-column:2;
  }
  body.learning-workspace-page #workspaceGridContainer #pnielAiWorkspace #pnielAiForm #pnielAiCharCount {
    position:absolute; bottom:1px; left:50%; transform:translateX(-50%);
  }
  body.learning-workspace-page #workspaceGridContainer #pnielAiWorkspace #pnielAiForm[data-composer-mode="ai_tutor"].has-photo :is(#pnielAiInput,#pnielAiSendBtn,#pnielAiPhotoHost) {
    grid-row:2;
  }
}
