/* Resource Portal — phone-width fixes (QA 10/9, BUG-00035).
   At 390px the header clipped the user's name/avatar, the editor toolbar
   overflowed, the library tabs were cut off and the "Ticket" tab covered
   content. Loaded last on every app page so these rules win. */
@media (max-width: 600px) {
  /* Header: breadcrumb shrinks with an ellipsis; name hides, avatar stays */
  .topbar, .app-topbar { padding: 0 12px !important; gap: 8px; min-width: 0; }
  .topbar-breadcrumb, .app-topbar-breadcrumb { flex: 1 1 auto; min-width: 0; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; font-size: 12px !important; }
  .topbar-right, .app-topbar-right { gap: 6px !important; flex-shrink: 0; min-width: 0; }
  #topbar-user-name, .topbar-user-name, .app-topbar-user-name { display: none !important; }
  .topbar-right > *, .app-topbar-right > * { flex-shrink: 0; }

  /* Tabs scroll sideways instead of clipping */
  .library-tabs, .tab-bar, .tabs-row, [role="tablist"] { display: flex !important; flex-wrap: nowrap !important;
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; gap: 6px; }
  .library-tabs::-webkit-scrollbar, .tab-bar::-webkit-scrollbar, .tabs-row::-webkit-scrollbar,
  [role="tablist"]::-webkit-scrollbar { display: none; }
  .library-tabs > *, .tab-bar > *, .tabs-row > *, [role="tablist"] > * { flex: 0 0 auto; white-space: nowrap; }

  /* Editor toolbar wraps into an even two-column grid of buttons */
  .bottom-bar { gap: 6px !important; padding: 10px !important; }
  .bottom-bar .bb-divider, .bottom-bar .bb-spacer { display: none !important; }
  .bottom-bar > .save-btn, .bottom-bar > button, .bottom-bar > a { flex: 1 1 calc(50% - 6px); justify-content: center; min-height: 40px; }

  /* Lesson editor: tighter side padding; its undo/Simplify/Adapt bar wraps */
  .editor-pane { padding: 16px 12px 80px !important; }
  .editor-toolbar, .editor-toolbar-group { flex-wrap: wrap !important; gap: 8px !important; }
  .editor-toolbar { padding: 8px 10px !important; }
  .editor-toolbar select { max-width: 100%; }

  /* Report-a-problem tab: a small round button in the corner, panel full width */
  .iw-trigger { top: auto !important; bottom: 84px !important; right: 12px !important; transform: none !important;
    writing-mode: horizontal-tb !important; border-radius: 999px !important; padding: 10px !important; }
  .iw-trigger .iw-label, .iw-trigger .iw-label-open { display: none !important; }
  .iw-panel { left: 8px !important; right: 8px !important; width: auto !important; top: auto !important;
    bottom: 8px !important; transform: none !important; max-height: calc(100vh - 24px) !important; }

  /* Modals fit the screen */
  .modal-card, .wizard-card { max-width: calc(100vw - 24px) !important; }
}
