/* Shared accessibility helper and mobile layout/touch-target fixes for standalone workspaces. */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 768px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Keep the drawing surface present when the app switches to a column layout. */
  .app-container {
    width: 100%;
    min-width: 0;
    min-height: 0;
  }

  /* Keep the hub's off-canvas navigation comfortably tappable on narrow phones. */
  .nav-item {
    min-height: 44px;
  }

  .canvas-container {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 500px;
    height: 500px;
  }

  .canvas-viewport,
  .workspace-viewport {
    min-width: 0;
    max-width: 100%;
  }

  /* Drawers must not participate in document width while they are closed. */
  .left-toolbar,
  .right-sidebar,
  .sidebar-overlay {
    position: fixed;
  }

  /* Prevent the off-canvas tool drawer's children from intercepting the backdrop. */
  .left-toolbar {
    overflow: hidden;
    pointer-events: none;
  }

  .left-toolbar.open {
    pointer-events: auto;
  }

  .right-sidebar {
    max-width: min(90vw, 360px);
  }

  .sidebar-tabs {
    overflow-x: auto;
    scrollbar-width: thin;
  }

  /* Make the controls comfortable to tap without changing desktop sizing. */
  .tool-btn,
  .mobile-toggle-btn,
  .vector-icon-btn,
  .delete-preset-btn,
  .vector-visibility-btn,
  .locate-node-btn,
  .minimap-toggle-btn,
  .modal-close-btn,
  .theme-toggle-btn,
  .mobile-menu-toggle {
    min-width: 44px;
    min-height: 44px;
  }

  input[type="range"] {
    min-height: 44px;
    touch-action: pan-x;
  }

  input[type="checkbox"] {
    min-width: 44px;
  }

  /* Custom switches hide the native input, so enlarge their label hit area too. */
  .switch-container {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }

  .switch-container .switch-slider {
    top: 12px;
    right: 10px;
    bottom: 12px;
    left: 0;
  }

  /* Flowchart's minimap is scaled to 85% on phones; compensate the toggle hit area. */
  .minimap-toggle-btn {
    min-width: 56px;
    min-height: 56px;
  }

  .tab-btn,
  .btn,
  .action-btn,
  button:not(.tool-btn):not(.mobile-toggle-btn):not(.delete-preset-btn),
  input:not([type="range"]):not([type="color"]),
  select,
  textarea {
    min-height: 44px;
  }

  input[type="color"] {
    min-width: 44px;
    min-height: 44px;
  }

  /* Keep this after the generic button rule so the scaled minimap stays tappable. */
  .minimap-toggle-btn {
    min-width: 56px;
    min-height: 56px !important;
    height: 56px !important;
  }
}
